【发布时间】:2021-10-27 08:54:47
【问题描述】:
我尝试运行的代码给了我一个错误:AssertionError: Torch not compiled with CUDA enabled。
我试图寻找解决这个问题的方法,但我发现很多解决方案都说同样的话。只需使用代码:
conda install pytorch torchvision cudatoolkit=10.2 -c pytorch
然后它应该可以工作了,因为之前安装 pytorch 时没有启用 CUDA。
但是,我的代码仍然返回完全相同的错误,我不知道为什么。我也尝试将cudatoolkit=10.2 更改为cudatoolkit=10.1,但结果相同。
关于更具体的信息,我上传了一些使用nvidia-smi 命令获得的细节:
另外我正在上传conda list制作的我的包列表
# Name Version Build Channel
_libgcc_mutex 0.1 main
_openmp_mutex 4.5 1_gnu
_pytorch_select 0.1 cpu_0
absl-py 0.15.0 pyhd8ed1ab_0 conda-forge
aiohttp 3.7.4.post0 py39h3811e60_0 conda-forge
async-timeout 3.0.1 py_1000 conda-forge
attrs 21.2.0 pyhd8ed1ab_0 conda-forge
blas 1.0 mkl
blinker 1.4 py_1 conda-forge
brotlipy 0.7.0 py39h3811e60_1001 conda-forge
bzip2 1.0.8 h7b6447c_0
c-ares 1.17.1 h27cfd23_0
ca-certificates 2021.9.30 h06a4308_1
cachetools 4.2.4 pyhd8ed1ab_0 conda-forge
certifi 2021.10.8 py39h06a4308_0
cffi 1.14.6 py39h400218f_0
chardet 4.0.0 py39hf3d152e_1 conda-forge
charset-normalizer 2.0.0 pyhd8ed1ab_0 conda-forge
click 8.0.3 py39hf3d152e_0 conda-forge
colorama 0.4.4 pyh9f0ad1d_0 conda-forge
cpuonly 2.0 0 pytorch
cryptography 35.0.0 py39hbca0aa6_0 conda-forge
cudatoolkit 10.2.89 hfd86e86_1
dataclasses 0.8 pyhc8e2a94_3 conda-forge
ffmpeg 4.3 hf484d3e_0 pytorch
freetype 2.10.4 h5ab3b9f_0
fsspec 2021.10.1 pyhd8ed1ab_0 conda-forge
future 0.18.2 py39hf3d152e_3 conda-forge
giflib 5.2.1 h7b6447c_0
gmp 6.2.1 h2531618_2
gnutls 3.6.15 he1e5248_0
google-auth 1.35.0 pyh6c4a22f_0 conda-forge
google-auth-oauthlib 0.4.6 pyhd8ed1ab_0 conda-forge
grpcio 1.37.1 py39hff7568b_0 conda-forge
idna 3.1 pyhd3deb0d_0 conda-forge
importlib-metadata 4.8.1 py39hf3d152e_0 conda-forge
intel-openmp 2019.4 243
jpeg 9d h7f8727e_0
lame 3.100 h7b6447c_0
lcms2 2.12 h3be6417_0
ld_impl_linux-64 2.35.1 h7274673_9
libffi 3.3 he6710b0_2
libgcc-ng 9.3.0 h5101ec6_17
libgfortran-ng 7.5.0 ha8ba4b0_17
libgfortran4 7.5.0 ha8ba4b0_17
libgomp 9.3.0 h5101ec6_17
libiconv 1.15 h63c8f33_5
libidn2 2.3.2 h7f8727e_0
libmklml 2019.0.5 0
libpng 1.6.37 hbc83047_0
libprotobuf 3.15.8 h780b84a_0 conda-forge
libstdcxx-ng 9.3.0 hd4cf53a_17
libtasn1 4.16.0 h27cfd23_0
libtiff 4.2.0 h85742a9_0
libunistring 0.9.10 h27cfd23_0
libuv 1.40.0 h7b6447c_0
libwebp 1.2.0 h89dd481_0
libwebp-base 1.2.0 h27cfd23_0
lz4-c 1.9.3 h295c915_1
markdown 3.3.4 pyhd8ed1ab_0 conda-forge
mkl 2020.2 256
mkl-service 2.3.0 py39he8ac12f_0
mkl_fft 1.3.0 py39h54f3939_0
mkl_random 1.0.2 py39h63df603_0
multidict 5.1.0 py39h27cfd23_2
ncurses 6.2 he6710b0_1
nettle 3.7.3 hbbd107a_1
ninja 1.10.2 hff7bd54_1
numpy 1.19.2 py39h89c1606_0
numpy-base 1.19.2 py39h2ae0177_0
oauthlib 3.1.1 pyhd8ed1ab_0 conda-forge
olefile 0.46 pyhd3eb1b0_0
openh264 2.1.0 hd408876_0
openssl 1.1.1l h7f8727e_0
packaging 21.0 pyhd8ed1ab_0 conda-forge
pillow 8.4.0 py39h5aabda8_0
pip 21.2.4 py39h06a4308_0
protobuf 3.15.8 py39he80948d_0 conda-forge
pyasn1 0.4.8 py_0 conda-forge
pyasn1-modules 0.2.7 py_0 conda-forge
pycparser 2.20 py_2
pydeprecate 0.3.1 pyhd8ed1ab_0 conda-forge
pyjwt 2.3.0 pyhd8ed1ab_0 conda-forge
pyopenssl 21.0.0 pyhd8ed1ab_0 conda-forge
pyparsing 2.4.7 pyh9f0ad1d_0 conda-forge
pysocks 1.7.1 py39hf3d152e_3 conda-forge
python 3.9.7 h12debd9_1
python_abi 3.9 2_cp39 conda-forge
pytorch 1.10.0 py3.9_cpu_0 pytorch
pytorch-lightning 1.4.9 pyhd8ed1ab_0 conda-forge
pytorch-mutex 1.0 cpu pytorch
pyu2f 0.1.5 pyhd8ed1ab_0 conda-forge
pyyaml 5.4.1 py39h3811e60_0 conda-forge
readline 8.1 h27cfd23_0
requests 2.26.0 pyhd8ed1ab_0 conda-forge
requests-oauthlib 1.3.0 pyh9f0ad1d_0 conda-forge
rsa 4.7.2 pyh44b312d_0 conda-forge
scipy 1.6.2 py39h91f5cce_0
setuptools 58.0.4 py39h06a4308_0
six 1.16.0 pyhd3eb1b0_0
sqlite 3.36.0 hc218d9a_0
tensorboard 2.6.0 pyhd8ed1ab_1 conda-forge
tensorboard-data-server 0.6.0 py39h3da14fd_0 conda-forge
tensorboard-plugin-wit 1.8.0 pyh44b312d_0 conda-forge
tk 8.6.11 h1ccaba5_0
torchmetrics 0.5.1 pyhd8ed1ab_0 conda-forge
torchvision 0.11.1 py39_cpu [cpuonly] pytorch
tqdm 4.62.3 pyhd8ed1ab_0 conda-forge
typing-extensions 3.10.0.2 hd3eb1b0_0
typing_extensions 3.10.0.2 pyh06a4308_0
tzdata 2021a h5d7bf9c_0
urllib3 1.26.7 pyhd8ed1ab_0 conda-forge
werkzeug 2.0.1 pyhd8ed1ab_0 conda-forge
wheel 0.37.0 pyhd3eb1b0_1
xz 5.2.5 h7b6447c_0
yaml 0.2.5 h516909a_0 conda-forge
yarl 1.6.3 py39h3811e60_2 conda-forge
zipp 3.6.0 pyhd8ed1ab_0 conda-forge
zlib 1.2.11 h7b6447c_3
zstd 1.4.9 haebb681_0
你能帮我解决这个问题吗?
【问题讨论】:
-
如果您收到
Torch not compiled with CUDA enabled错误,那么您在某处安装了仅 CPU 版本的 Torch,并且您正在运行的 Python 版本 正在查找该版本。可能是您也有多个 Python 版本和或/环境 -
我在使用 python 3.9 的环境中的
ssh服务器上运行它。你认为可能是我有几个 python 版本的情况吗? -
绝对,是的。除非您控制 PATH 以便首先找到 anaconda 安装,否则您很可能没有运行您认为的运行
-
我了解问题所在,但我不知道如何防止自己出现这些错误。你能否证明我应该做些什么来确保我运行我想要运行的东西?
-
这需要有关我没有的有关服务器的各种详细信息,所以不,我真的无法为您提供帮助
标签: python windows powershell pytorch