jcwleo / random-network-distillation-pytorch

Random Network Distillation pytorch
MIT License
241 stars 43 forks source link

TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first #14

Closed kslazarev closed 5 years ago

kslazarev commented 5 years ago

Problem: TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first. GPU only problem.

Traceback (most recent call last):
  File "train.py", line 274, in <module>
    main()
  File "train.py", line 216, in main
    total_logging_policy = np.vstack(total_policy)
  File "/home/deployer/.pyenv/versions/3.6.8/envs/general/lib/python3.6/site-packages/numpy/core/shape_base.py", line 234, in vstack
    return _nx.concatenate([atleast_2d(_m) for _m in tup], 0)
  File "/home/deployer/.pyenv/versions/3.6.8/envs/general/lib/python3.6/site-packages/numpy/core/shape_base.py", line 234, in <listcomp>
    return _nx.concatenate([atleast_2d(_m) for _m in tup], 0)
  File "/home/deployer/.pyenv/versions/3.6.8/envs/general/lib/python3.6/site-packages/numpy/core/shape_base.py", line 102, in atleast_2d
    ary = asanyarray(ary)
  File "/home/deployer/.pyenv/versions/3.6.8/envs/general/lib/python3.6/site-packages/numpy/core/numeric.py", line 553, in asanyarray
    return array(a, dtype, copy=False, order=order, subok=True)
  File "/home/deployer/.pyenv/versions/3.6.8/envs/general/lib/python3.6/site-packages/torch/tensor.py", line 450, in __array__
    return self.numpy()
TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
jcwleo commented 5 years ago

LGTM

jcwleo commented 5 years ago

Thank you for commit :)