Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. #16

Open
OneWorld-github opened this issue May 28, 2020 · 2 comments

Comments

@OneWorld-github
Copy link

OneWorld-github commented May 28, 2020

when I run this command (taken from the instructions page https://github.com/seoungwugoh/STM ) after running through the install

(STMVOS) C:\Users\OneWorld\Documents\DeepLearning\VideoObjectSegmentation\STMVOS>python eval_DAVIS.py -g '1' -s val -y 16 -D C:\Users\OneWorld\Documents\DeepLearning\VideoObjectSegmentation\DAVISSemiSupervisedTrainVal480

It gets this far

Space-time Memory Networks: initialized.
STM : Testing on DAVIS
Downloading: "https://download.pytorch.org/models/resnet50-19c8e357.pth" to C:\Users\OneWorld/.cache\torch\checkpoints\resnet50-19c8e357.pth
100%|██████████████████████████████████████████████████████████████████████████| 97.8M/97.8M [00:09<00:00, 10.7MB/s]
Loading weights: STM_weights.pth

and then I see this error

Traceback (most recent call last):
  File "eval_DAVIS.py", line 111, in <module>
    model.load_state_dict(torch.load(pth_path))
  File "C:\Users\OneWorld\anaconda3\envs\STMVOS\lib\site-packages\torch\serialization.py", line 593, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "C:\Users\OneWorld\anaconda3\envs\STMVOS\lib\site-packages\torch\serialization.py", line 773, in _legacy_load
    result = unpickler.load()
  File "C:\Users\OneWorld\anaconda3\envs\STMVOS\lib\site-packages\torch\serialization.py", line 729, in persistent_load
    deserialized_objects[root_key] = restore_location(obj, location)
  File "C:\Users\OneWorld\anaconda3\envs\STMVOS\lib\site-packages\torch\serialization.py", line 178, in default_restore_location
    result = fn(storage, location)
  File "C:\Users\OneWorld\anaconda3\envs\STMVOS\lib\site-packages\torch\serialization.py", line 154, in _cuda_deserialize
    device = validate_cuda_device(location)
  File "C:\Users\OneWorld\anaconda3\envs\STMVOS\lib\site-packages\torch\serialization.py", line 138, in validate_cuda_device
    raise RuntimeError('Attempting to deserialize object on a CUDA '
RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.

I am using Windows 10.

# packages in environment at C:\Users\OneWorld\anaconda3\envs\STMVOS:
#
# Name                    Version                   Build  Channel
blas                      1.0                         mkl
ca-certificates           2020.1.1                      0
certifi                   2020.4.5.1               py38_0
cuda100                   1.0                           0    pytorch
cudatoolkit               10.2.89              h74a9793_1
cycler                    0.10.0                   py38_0
freetype                  2.9.1                ha9979f8_1
hdf5                      1.10.4               h7ebc959_0
icc_rt                    2019.0.0             h0cc432a_1
icu                       58.2                 ha925a31_3
intel-openmp              2020.1                      216
jpeg                      9b                   hb83a4c4_2
kiwisolver                1.2.0            py38h74a9793_0
libopencv                 4.0.1                hbb9e17c_0
libpng                    1.6.37               h2a8f88b_0
libtiff                   4.1.0                h56a325e_0
matplotlib                3.1.3                    py38_0
matplotlib-base           3.1.3            py38h64f37c6_0
mkl                       2020.1                      216
mkl-service               2.3.0            py38hb782905_0
mkl_fft                   1.0.15           py38h14836fe_0
mkl_random                1.1.1            py38h47e9c7a_0
ninja                     1.9.0            py38h74a9793_0
numpy                     1.18.1           py38h93ca92e_0
numpy-base                1.18.1           py38hc3f5095_1
olefile                   0.46                       py_0
opencv                    4.0.1            py38h2a7c758_0
openssl                   1.1.1g               he774522_0
pillow                    7.1.2            py38hcc1f983_0
pip                       20.0.2                   py38_3
py-opencv                 4.0.1            py38he44ac1e_0
pyparsing                 2.4.7                      py_0
pyqt                      5.9.2            py38ha925a31_4
python                    3.8.3                he1778fa_0
python-dateutil           2.8.1                      py_0
pytorch                   1.5.0           py3.8_cuda102_cudnn7_0    pytorch
qt                        5.9.7            vc14h73c81de_0
setuptools                46.4.0                   py38_0
sip                       4.19.13          py38ha925a31_0
six                       1.14.0                   py38_0
sqlite                    3.31.1               h2a8f88b_1
tk                        8.6.8                hfa6e2cd_0
torchvision               0.6.0                py38_cu102    pytorch
tornado                   6.0.4            py38he774522_1
tqdm                      4.46.0                     py_0
vc                        14.1                 h0510ff6_4
vs2015_runtime            14.16.27012          hf0eaf9b_2
wheel                     0.34.2                   py38_0
wincertstore              0.2                      py38_0
xz                        5.2.5                h62dcd97_0
zlib                      1.2.11               h62dcd97_4
zstd                      1.3.7                h508b16e_0

     active environment : STMVOS
    active env location : C:\Users\OneWorld\anaconda3\envs\STMVOS
            shell level : 2
       user config file : C:\Users\OneWorld\.condarc
 populated config files : C:\Users\OneWorld\.condarc
          conda version : 4.8.2
    conda-build version : 3.18.11
         python version : 3.7.6.final.0
       virtual packages : __cuda=10.2
       base environment : C:\Users\OneWorld\anaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\Users\OneWorld\anaconda3\pkgs
                          C:\Users\OneWorld\.conda\pkgs
                          C:\Users\OneWorld\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\OneWorld\anaconda3\envs
                          C:\Users\OneWorld\.conda\envs
                          C:\Users\OneWorld\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.8.2 requests/2.22.0 CPython/3.7.6 Windows/10 Windows/10.0.17134
          administrator : False
             netrc file : None
           offline mode : False

I have added some more detail into things I have tried in the following stack overflow link:-
https://stackoverflow.com/questions/62088265/runtimeerror-attempting-to-deserialize-object-on-a-cuda-device-but-torch-cuda-i
I tried in Ubuntu aswell

Any ideas how to get an NVIDIA Geforce 1070 GPU to work with STM ?

@OneWorld-github
Copy link
Author

@qixiong-wang
Copy link

Set num_workers=0 as follow
Testloader = data.DataLoader(Testset, batch_size=1, shuffle=False, num_workers=0, pin_memory=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants