# Load\_checkpoint\_and\_dispatch checkpoint value error using Sagemaker

**URL:** <https://discuss.huggingface.co/t/load-checkpoint-and-dispatch-checkpoint-value-error-using-sagemaker/64743>\
**Category:** 🤗Accelerate\
**Created:** [December 6, 2023, 6:35am UTC](https://discuss.huggingface.co/t/load-checkpoint-and-dispatch-checkpoint-value-error-using-sagemaker/64743 "2023-12-06T06:35:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Soraheart1988](https://avatars.discourse-cdn.com/v4/letter/s/e9a140/32.png) [@Soraheart1988](https://discuss.huggingface.co/u/Soraheart1988)\
**Post date:** [December 6, 2023, 6:35am UTC](https://discuss.huggingface.co/t/load-checkpoint-and-dispatch-checkpoint-value-error-using-sagemaker/64743/1 "2023-12-06T06:35:59Z")

</div>

Hi, I am following the CogVLM Model. [https://huggingface.co/THUDM/cogvlm-chat-hf](https://huggingface.co/THUDM/cogvlm-chat-hf)

I have spinup at sagemaker instance of ml.g4dn.12xlarge with 4x16 GPU.

I tried follow the code specified in above huggingface link, but face error at the _load\_checkpoint\_and\_dispatch_

> Blockquote  
> model = load\_checkpoint\_and\_dispatch(  
> model,  
> “~/.cache/huggingface/hub/models–THUDM–cogvlm-chat-hf/snapshots/54b93e0af3f1d8badcdeefdb0d26b1dfbc227f7a/”, # typical, ‘~/.cache/huggingface/hub/models–THUDM–cogvlm-chat-hf/snapshots/balabala’  
> device\_map=device\_map,  
> )

**This is the results of the !ls ~/.cache/huggingface/hub/models–THUDM–cogvlm-chat-hf/snapshots/54b93e0af3f1d8badcdeefdb0d26b1dfbc227f7a/**

config.json model-00005-of-00008.safetensors  
configuration\_cogvlm.py model-00006-of-00008.safetensors  
generation\_config.json model-00007-of-00008.safetensors  
model-00001-of-00008.safetensors model-00008-of-00008.safetensors  
model-00002-of-00008.safetensors modeling\_cogvlm.py  
model-00003-of-00008.safetensors model.safetensors.index.json  
model-00004-of-00008.safetensors visual.py

**This is the error message**  
ValueError: `checkpoint` should be the path to a file containing a whole state dict, or the index of a sharded checkpoint, or a folder containing a sharded checkpoint or the whole state dict, but got ~/.cache/huggingface/hub/models–THUDM–cogvlm-chat-hf/snapshots/54b93e0af3f1d8badcdeefdb0d26b1dfbc227f7a/.

---

<div class="post-metadata">

**Author:** ![tomasremitz](https://avatars.discourse-cdn.com/v4/letter/t/73ab20/32.png) [@tomasremitz](https://discuss.huggingface.co/u/tomasremitz)\
**Post date:** [December 26, 2023, 3:23pm UTC](https://discuss.huggingface.co/t/load-checkpoint-and-dispatch-checkpoint-value-error-using-sagemaker/64743/2 "2023-12-26T15:23:22Z")

</div>

Hi!  
Have you tried replacing it for a full path instead of a relative one?

---

<div class="post-metadata">

**Author:** ![marcsun13](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/marcsun13/32/19059_2.png) [@marcsun13](https://discuss.huggingface.co/u/marcsun13)\
**Post date:** [January 24, 2024, 3:30pm UTC](https://discuss.huggingface.co/t/load-checkpoint-and-dispatch-checkpoint-value-error-using-sagemaker/64743/3 "2024-01-24T15:30:48Z")

</div>

Hii @Soraheart1988, were you able to solve your issue ? as @tomasremitz said, you should probably try to put the absolute path.

---

<div class="post-metadata">

**Author:** ![silverquimera](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@silverquimera](https://discuss.huggingface.co/u/silverquimera)\
**Post date:** [March 28, 2024, 7:09am UTC](https://discuss.huggingface.co/t/load-checkpoint-and-dispatch-checkpoint-value-error-using-sagemaker/64743/4 "2024-03-28T07:09:32Z")

</div>

Just for reference to other folks. The following worked for me:

```auto
path_to_index = '/root/.cache/.../model.safetensors.index.json'
model = load_checkpoint_and_dispatch(
    model,
    path_to_index,   
    device_map=device_map,
)

```

Notice the `/root/...`.

---

<div class="post-metadata">

**Author:** ![Soraheart1988](https://avatars.discourse-cdn.com/v4/letter/s/e9a140/32.png) [@Soraheart1988](https://discuss.huggingface.co/u/Soraheart1988)\
**Post date:** [March 28, 2024, 8:21am UTC](https://discuss.huggingface.co/t/load-checkpoint-and-dispatch-checkpoint-value-error-using-sagemaker/64743/5 "2024-03-28T08:21:27Z")

</div>

Thanks all, manage to solve it by using the absolute path.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](https://discuss.huggingface.co/u/system)\
**Post date:** [March 28, 2024, 8:21pm UTC](https://discuss.huggingface.co/t/load-checkpoint-and-dispatch-checkpoint-value-error-using-sagemaker/64743/6 "2024-03-28T20:21:38Z")

</div>

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
