Moemu / Muice-Chatbot

沐雪,一个会自动找你聊天的AI女孩子
MIT License
269 stars 21 forks source link

AssertionError: Torch not compiled with CUDA enabled #2

Closed TurboHK closed 1 year ago

TurboHK commented 1 year ago

運行環境 Windows 11 Pro,conda 23.5.2

顯示卡 NVIDIA GeForce RTX 4060

過程(復現) 在安裝完所有組件後,於 Muice-Chatbot-main 啓動 Windows Terminal,依次執行conda activate Muicepython main.py,會產生AssertionError: Torch not compiled with CUDA enabled 錯誤。

檔案結構

├─Muice-Chatbot-main   <- 主路徑
│  ├─__pycache__
│  ├─llm
│  ├─model
│       ├─ chatglm2-6b
│       ├─ Muice
│  ├─qqbot
│  └─src
├─main.py  <- 主處理程式
└─...

完整輸出

Microsoft Windows [Version 10.0.22621.2134]
(c) Microsoft Corporation. All rights reserved.

C:\Users\[已略去]\Desktop\Muice\Muice-Chatbot-main>conda activate Muice

(Muice) C:\Users\[已略去]\Desktop\Muice\Muice-Chatbot-main>python main.py
Loading checkpoint shards: 100%|█████████████████████████████████████████████████████████| 7/7 [00:08<00:00,  1.17s/it]
Some weights of ChatGLMForConditionalGeneration were not initialized from the model checkpoint at model/chatglm2-6b and are newly initialized: ['transformer.prefix_encoder.embedding.weight']
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.
Traceback (most recent call last):
  File "C:\Users\[已略去]\Desktop\Muice\Muice-Chatbot-main\main.py", line 10, in <module>
    model = Model('model/chatglm2-6b','model/Muice')
  File "C:\Users\[已略去]\Desktop\Muice\Muice-Chatbot-main\llm\chatglm2.py", line 14, in __init__
    model = AutoModel.from_pretrained(model_path, config=config, trust_remote_code=True).half().to(device)
  File "C:\Users\[已略去]\.conda\envs\Muice\lib\site-packages\transformers\modeling_utils.py", line 1900, in to
    return super().to(*args, **kwargs)
  File "C:\Users\[已略去]\.conda\envs\Muice\lib\site-packages\torch\nn\modules\module.py", line 1145, in to
    return self._apply(convert)
  File "C:\Users\[已略去]\.conda\envs\Muice\lib\site-packages\torch\nn\modules\module.py", line 797, in _apply
    module._apply(fn)
  File "C:\Users\[已略去]\.conda\envs\Muice\lib\site-packages\torch\nn\modules\module.py", line 797, in _apply
    module._apply(fn)
  File "C:\Users\[已略去]\.conda\envs\Muice\lib\site-packages\torch\nn\modules\module.py", line 797, in _apply
    module._apply(fn)
  File "C:\Users\[已略去]\.conda\envs\Muice\lib\site-packages\torch\nn\modules\module.py", line 820, in _apply
    param_applied = fn(param)
  File "C:\Users\[已略去]\.conda\envs\Muice\lib\site-packages\torch\nn\modules\module.py", line 1143, in convert
    return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking)
  File "C:\Users\[已略去]\.conda\envs\Muice\lib\site-packages\torch\cuda\__init__.py", line 239, in _lazy_init
    raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled

(Muice) C:\Users\[已略去]\Desktop\Muice\Muice-Chatbot-main>
fanqiNO1 commented 1 year ago

这看起来是因为您并没有安装cuda版本的pytorch,您可以按照 https://pytorch.org/get-started/locally/ 中的指引进行安装,比如 conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia

TurboHK commented 1 year ago

这看起来是因为您并没有安装cuda版本的pytorch,您可以按照 https://pytorch.org/get-started/locally/ 中的指引进行安装,比如 conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia

事實上,我已經安裝了支援 CUDA 的 pytorch,以下是使用 Python Shell 的結果。 完整輸出:

Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.cuda.is_available())
True
fanqiNO1 commented 1 year ago

如果可以的话,您方便展示一下 pip list 或者 conda list 中关于 torch/pytorch 部分的结果吗?

TurboHK commented 1 year ago

如果可以的话,您方便展示一下 pip list 或者 conda list 中关于 torch/pytorch 部分的结果吗?

當然。

pip list

Package            Version
------------------ ------------
certifi            2023.7.22
charset-normalizer 3.2.0
filelock           3.9.0
idna               3.4
Jinja2             3.1.2
MarkupSafe         2.1.2
mpmath             1.2.1
networkx           3.0
numpy              1.24.1
Pillow             10.0.0
pip                23.0.1
pycryptodome       3.18.0
requests           2.31.0
setuptools         65.5.0
sympy              1.11.1
torch              2.0.1+cu118
torchaudio         2.0.2+cu118
torchvision        0.15.2+cu118
typing_extensions  4.4.0
urllib3            2.0.4
websockets         11.0.3

[notice] A new release of pip is available: 23.0.1 -> 23.2.1
[notice] To update, run: python.exe -m pip install --upgrade pip

conda list

# packages in environment at C:\ProgramData\miniconda3:
#
# Name                    Version                   Build  Channel
blas                      1.0                         mkl
boltons                   23.0.0          py311haa95532_0
brotlipy                  0.7.0           py311h2bbff1b_1002
bzip2                     1.0.8                he774522_0
ca-certificates           2023.08.22           haa95532_0
certifi                   2023.7.22       py311haa95532_0
cffi                      1.15.1          py311h2bbff1b_3
charset-normalizer        2.0.4              pyhd3eb1b0_0
colorama                  0.4.6           py311haa95532_0
conda                     23.7.3          py311haa95532_0
conda-content-trust       0.1.3           py311haa95532_0
conda-libmamba-solver     23.5.0          py311haa95532_0
conda-package-handling    2.2.0           py311haa95532_0
conda-package-streaming   0.9.0           py311haa95532_0
console_shortcut_miniconda 0.1.1                haa95532_1
cryptography              39.0.1          py311h21b164f_2
cuda-cccl                 12.2.140                      0    nvidia
cuda-cudart               11.8.89                       0    nvidia
cuda-cudart-dev           11.8.89                       0    nvidia
cuda-cupti                11.8.87                       0    nvidia
cuda-libraries            11.8.0                        0    nvidia
cuda-libraries-dev        11.8.0                        0    nvidia
cuda-nvrtc                11.8.89                       0    nvidia
cuda-nvrtc-dev            11.8.89                       0    nvidia
cuda-nvtx                 11.8.86                       0    nvidia
cuda-profiler-api         12.2.140                      0    nvidia
cuda-runtime              11.8.0                        0    nvidia
filelock                  3.9.0           py311haa95532_0
fmt                       9.1.0                h6d14046_0
freetype                  2.12.1               ha860e81_0
giflib                    5.2.1                h8cc25b3_3
idna                      3.4             py311haa95532_0
intel-openmp              2023.1.0         h59b6b97_46319
jinja2                    3.1.2           py311haa95532_0
jpeg                      9e                   h2bbff1b_1
jsonpatch                 1.32               pyhd3eb1b0_0
jsonpointer               2.1                pyhd3eb1b0_0
lerc                      3.0                  hd77b12b_0
libarchive                3.6.2                hb62f4d4_2
libcublas                 11.11.3.6                     0    nvidia
libcublas-dev             11.11.3.6                     0    nvidia
libcufft                  10.9.0.58                     0    nvidia
libcufft-dev              10.9.0.58                     0    nvidia
libcurand                 10.3.3.141                    0    nvidia
libcurand-dev             10.3.3.141                    0    nvidia
libcurl                   8.1.1                h86230a5_0
libcusolver               11.4.1.48                     0    nvidia
libcusolver-dev           11.4.1.48                     0    nvidia
libcusparse               11.7.5.86                     0    nvidia
libcusparse-dev           11.7.5.86                     0    nvidia
libdeflate                1.17                 h2bbff1b_0
libffi                    3.4.4                hd77b12b_0
libiconv                  1.16                 h2bbff1b_2
libmamba                  1.4.1                h77c03ed_1
libmambapy                1.4.1           py311h77c03ed_1
libnpp                    11.8.0.86                     0    nvidia
libnpp-dev                11.8.0.86                     0    nvidia
libnvjpeg                 11.9.0.86                     0    nvidia
libnvjpeg-dev             11.9.0.86                     0    nvidia
libpng                    1.6.39               h8cc25b3_0
libsolv                   0.7.24               h23ce68f_0
libssh2                   1.10.0               he2ea4bf_2
libtiff                   4.5.1                hd77b12b_0
libuv                     1.44.2               h2bbff1b_0
libwebp                   1.2.4                hbc33d0d_1
libwebp-base              1.2.4                h2bbff1b_1
libxml2                   2.10.4               h0ad7f3c_1
lz4-c                     1.9.4                h2bbff1b_0
markupsafe                2.1.1           py311h2bbff1b_0
menuinst                  1.4.19          py311h59b6b97_1
mkl                       2023.1.0         h6b88ed4_46357
mkl-service               2.4.0           py311h2bbff1b_1
mkl_fft                   1.3.6           py311hf62ec03_1
mkl_random                1.2.2           py311hf62ec03_1
mpmath                    1.3.0           py311haa95532_0
networkx                  3.1             py311haa95532_0
numpy                     1.25.2          py311hdab7c0b_0
numpy-base                1.25.2          py311hd01c5d8_0
openssl                   3.0.10               h2bbff1b_2
packaging                 23.1            py311haa95532_0
pcre2                     10.42                h0ff8eda_0
pillow                    9.4.0           py311hd77b12b_0
pip                       23.1.2          py311haa95532_0
pluggy                    1.0.0           py311haa95532_1
powershell_shortcut_miniconda 0.0.1                haa95532_1
pybind11-abi              4                    hd3eb1b0_1
pycosat                   0.6.4           py311h2bbff1b_0
pycparser                 2.21               pyhd3eb1b0_0
pyopenssl                 23.2.0          py311haa95532_0
pysocks                   1.7.1           py311haa95532_0
python                    3.11.4               he1021f5_0
pytorch                   2.0.1           py3.11_cuda11.8_cudnn8_0    pytorch
pytorch-cuda              11.8                 h24eeafa_5    pytorch
pytorch-mutex             1.0                        cuda    pytorch
reproc                    14.2.4               hd77b12b_1
reproc-cpp                14.2.4               hd77b12b_1
requests                  2.31.0          py311haa95532_0
ruamel.yaml               0.17.21         py311h2bbff1b_0
setuptools                67.8.0          py311haa95532_0
six                       1.16.0             pyhd3eb1b0_1
sqlite                    3.41.2               h2bbff1b_0
sympy                     1.11.1          py311haa95532_0
tbb                       2021.8.0             h59b6b97_0
tk                        8.6.12               h2bbff1b_0
toolz                     0.12.0          py311haa95532_0
torchaudio                2.0.2                    pypi_0    pypi
torchvision               0.15.2                   pypi_0    pypi
tqdm                      4.65.0          py311h746a85d_0
typing_extensions         4.7.1           py311haa95532_0
tzdata                    2023c                h04d1e81_0
urllib3                   1.26.16         py311haa95532_0
vc                        14.2                 h21ff451_1
vs2015_runtime            14.27.29016          h5e58377_2
wheel                     0.38.4          py311haa95532_0
win_inet_pton             1.1.0           py311haa95532_0
xz                        5.4.2                h8cc25b3_0
yaml-cpp                  0.7.0                hd77b12b_1
zlib                      1.2.13               h8cc25b3_0
zstandard                 0.19.0          py311h2bbff1b_0
zstd                      1.5.5                hd43e919_0

我似乎同時安裝了 anaconda3 和 miniconda3,這會是原因嗎?

fanqiNO1 commented 1 year ago

这看起来似乎 conda list 所展示的环境信息与您运行程序时所使用的环境并不一致。 conda list 显示您的 python 版本为 3.11

这看起来是因为您并没有安装cuda版本的pytorch,您可以按照 https://pytorch.org/get-started/locally/ 中的指引进行安装,比如 conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia

事實上,我已經安裝了支援 CUDA 的 pytorch,以下是使用 Python Shell 的結果。 完整輸出:

Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.cuda.is_available())
True

而这里 python 版本又为 3.10,您可以检查一下用来执行程序的环境中 pytorch 相关版本

TurboHK commented 1 year ago

这看起来似乎 conda list 所展示的环境信息与您运行程序时所使用的环境并不一致。 conda list 显示您的 python 版本为 3.11

这看起来是因为您并没有安装cuda版本的pytorch,您可以按照 https://pytorch.org/get-started/locally/ 中的指引进行安装,比如 conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia

事實上,我已經安裝了支援 CUDA 的 pytorch,以下是使用 Python Shell 的結果。 完整輸出:

Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.cuda.is_available())
True

而这里 python 版本又为 3.10,您可以检查一下用来执行程序的环境中 pytorch 相关版本

我修復了這個問題,但又產生了新的問題。 再次運行 python main.py 時,報出 ModuleNotFoundError: No module named 'cchardet' 。在使用 pip install cchardet 後,報出 error: Microsoft Visual C++ 14.0 or greater is required. 以及 ERROR: Could not build wheels for cchardet, which is required to install pyproject.toml-based projects 。但我的 Microsoft Visual C++ 版本為 14.36.32532.0,也已經安裝了 toml。

完整 Windows Terminal 輸出如下

Microsoft Windows [Version 10.0.22621.2134]
(c) Microsoft Corporation. All rights reserved.

C:\Users\[已略去]\Desktop\Muice>conda activate Muice

(Muice) C:\Users\[已略去]\Desktop\Muice>python main.py
Traceback (most recent call last):
  File "C:\Users\[已略去]\.conda\envs\Muice\lib\site-packages\aiohttp\client_reqrep.py", line 70, in <module>
    import cchardet as chardet
ModuleNotFoundError: No module named 'cchardet'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\[已略去]\Desktop\Muice\main.py", line 2, in <module>
    from qqbot import qqbot
  File "C:\Users\[已略去]\Desktop\Muice\qqbot.py", line 1, in <module>
    from pycqBot.cqHttpApi import cqHttpApi, cqLog
  File "C:\Users\[已略去]\.conda\envs\Muice\lib\site-packages\pycqBot\__init__.py", line 1, in <module>
    from pycqBot.cqHttpApi import cqBot, cqHttpApi, cqLog
  File "C:\Users\[已略去]\.conda\envs\Muice\lib\site-packages\pycqBot\cqHttpApi.py", line 18, in <module>
    from pycqBot.cqApi import Api
  File "C:\Users\[已略去]\.conda\envs\Muice\lib\site-packages\pycqBot\cqApi.py", line 2, in <module>
    from pycqBot.asyncHttp import asyncHttp
  File "C:\Users\[已略去]\.conda\envs\Muice\lib\site-packages\pycqBot\asyncHttp.py", line 5, in <module>
    import aiohttp
  File "C:\Users\[已略去]\.conda\envs\Muice\lib\site-packages\aiohttp\__init__.py", line 6, in <module>
    from .client import (
  File "C:\Users\[已略去]\.conda\envs\Muice\lib\site-packages\aiohttp\client.py", line 59, in <module>
    from .client_reqrep import (
  File "C:\Users\[已略去]\.conda\envs\Muice\lib\site-packages\aiohttp\client_reqrep.py", line 72, in <module>
    import charset_normalizer as chardet  # type: ignore[no-redef]
  File "C:\Users\[已略去]\.conda\envs\Muice\lib\site-packages\charset_normalizer\__init__.py", line 23, in <module>
    from charset_normalizer.api import from_fp, from_path, from_bytes, normalize
  File "C:\Users\[已略去]\.conda\envs\Muice\lib\site-packages\charset_normalizer\api.py", line 10, in <module>
    from charset_normalizer.md import mess_ratio
  File "charset_normalizer\md.py", line 5, in <module>
ImportError: cannot import name 'COMMON_SAFE_ASCII_CHARACTERS' from 'charset_normalizer.constant' (C:\Users[已略去]\.conda\envs\Muice\lib\site-packages\charset_normalizer\constant.py)

(Muice) C:\Users\[已略去]\Desktop\Muice>pip install cchardet
Collecting cchardet
  Using cached cchardet-2.1.7.tar.gz (653 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: cchardet
  Building wheel for cchardet (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      cythonize: ['src/cchardet\\_cchardet.pyx']
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-310
      creating build\lib.win-amd64-cpython-310\cchardet
      copying src\cchardet\version.py -> build\lib.win-amd64-cpython-310\cchardet
      copying src\cchardet\__init__.py -> build\lib.win-amd64-cpython-310\cchardet
      running build_ext
      building 'cchardet._cchardet' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for cchardet
  Running setup.py clean for cchardet
Failed to build cchardet
ERROR: Could not build wheels for cchardet, which is required to install pyproject.toml-based projects

conda list 輸出如下

(Muice) C:\Users\[已略去]\Desktop\Muice>conda list
# packages in environment at C:\Users\turbo\.conda\envs\Muice:
#
# Name                    Version                   Build  Channel
aiofiles                  23.2.1                   pypi_0    pypi
aiohttp                   3.8.5                    pypi_0    pypi
aiosignal                 1.3.1                    pypi_0    pypi
async-timeout             4.0.3                    pypi_0    pypi
asyncio                   3.4.3                    pypi_0    pypi
attrs                     23.1.0                   pypi_0    pypi
blas                      1.0                         mkl
brotlipy                  0.7.0           py310h2bbff1b_1002
bzip2                     1.0.8                he774522_0
ca-certificates           2023.08.22           haa95532_0
certifi                   2023.7.22       py310haa95532_0
cffi                      1.15.1          py310h2bbff1b_3
charset-normalizer        3.2.0                    pypi_0    pypi
colorama                  0.4.6                    pypi_0    pypi
cryptography              41.0.2          py310h31511bf_0
cuda-cccl                 12.2.140                      0    nvidia
cuda-cudart               11.8.89                       0    nvidia
cuda-cudart-dev           11.8.89                       0    nvidia
cuda-cupti                11.8.87                       0    nvidia
cuda-libraries            11.8.0                        0    nvidia
cuda-libraries-dev        11.8.0                        0    nvidia
cuda-nvrtc                11.8.89                       0    nvidia
cuda-nvrtc-dev            11.8.89                       0    nvidia
cuda-nvtx                 11.8.86                       0    nvidia
cuda-profiler-api         12.2.140                      0    nvidia
cuda-runtime              11.8.0                        0    nvidia
cython                    3.0.2                    pypi_0    pypi
filelock                  3.12.3                   pypi_0    pypi
freetype                  2.12.1               ha860e81_0
frozenlist                1.4.0                    pypi_0    pypi
fsspec                    2023.9.0                 pypi_0    pypi
giflib                    5.2.1                h8cc25b3_3
huggingface-hub           0.16.4                   pypi_0    pypi
idna                      3.4             py310haa95532_0
intel-openmp              2023.1.0         h59b6b97_46319
jinja2                    3.1.2           py310haa95532_0
jpeg                      9e                   h2bbff1b_1
jsonschema                4.19.0                   pypi_0    pypi
jsonschema-specifications 2023.7.1                 pypi_0    pypi
lerc                      3.0                  hd77b12b_0
libcublas                 11.11.3.6                     0    nvidia
libcublas-dev             11.11.3.6                     0    nvidia
libcufft                  10.9.0.58                     0    nvidia
libcufft-dev              10.9.0.58                     0    nvidia
libcurand                 10.3.3.141                    0    nvidia
libcurand-dev             10.3.3.141                    0    nvidia
libcusolver               11.4.1.48                     0    nvidia
libcusolver-dev           11.4.1.48                     0    nvidia
libcusparse               11.7.5.86                     0    nvidia
libcusparse-dev           11.7.5.86                     0    nvidia
libdeflate                1.17                 h2bbff1b_0
libffi                    3.4.4                hd77b12b_0
libnpp                    11.8.0.86                     0    nvidia
libnpp-dev                11.8.0.86                     0    nvidia
libnvjpeg                 11.9.0.86                     0    nvidia
libnvjpeg-dev             11.9.0.86                     0    nvidia
libpng                    1.6.39               h8cc25b3_0
libtiff                   4.5.1                hd77b12b_0
libuv                     1.44.2               h2bbff1b_0
libwebp                   1.2.4                hbc33d0d_1
libwebp-base              1.2.4                h2bbff1b_1
lxml                      4.9.3                    pypi_0    pypi
lz4-c                     1.9.4                h2bbff1b_0
markupsafe                2.1.3                    pypi_0    pypi
mkl                       2023.1.0         h6b88ed4_46357
mkl-service               2.4.0           py310h2bbff1b_1
mkl_fft                   1.3.6           py310h4ed8f06_1
mkl_random                1.2.2           py310h4ed8f06_1
mpmath                    1.3.0           py310haa95532_0
multidict                 6.0.4                    pypi_0    pypi
networkx                  3.1             py310haa95532_0
numpy                     1.25.2          py310h055cbcc_0
numpy-base                1.25.2          py310h65a83cf_0
openssl                   1.1.1v               h2bbff1b_0
packaging                 23.1                     pypi_0    pypi
pillow                    9.4.0           py310hd77b12b_0
pip                       23.2.1          py310haa95532_0
pycparser                 2.21               pyhd3eb1b0_0
pycqbot                   0.5.1.1                  pypi_0    pypi
pyopenssl                 23.2.0          py310haa95532_0
pyproject-toml            0.0.10                   pypi_0    pypi
pysocks                   1.7.1           py310haa95532_0
python                    3.10.9               h966fe2a_2
pytorch                   2.0.1           py3.10_cuda11.8_cudnn8_0    pytorch
pytorch-cuda              11.8                 h24eeafa_5    pytorch
pytorch-mutex             1.0                        cuda    pytorch
pyyaml                    6.0.1                    pypi_0    pypi
referencing               0.30.2                   pypi_0    pypi
regex                     2023.8.8                 pypi_0    pypi
requests                  2.31.0          py310haa95532_0
rpds-py                   0.10.2                   pypi_0    pypi
safetensors               0.3.3                    pypi_0    pypi
sentencepiece             0.1.99                   pypi_0    pypi
setuptools                68.0.0          py310haa95532_0
sqlite                    3.41.2               h2bbff1b_0
sympy                     1.12                     pypi_0    pypi
tbb                       2021.8.0             h59b6b97_0
tk                        8.6.12               h2bbff1b_0
tokenizers                0.13.3                   pypi_0    pypi
toml                      0.10.2                   pypi_0    pypi
torch                     2.0.1                    pypi_0    pypi
torchaudio                2.0.2                    pypi_0    pypi
torchvision               0.15.2                   pypi_0    pypi
tqdm                      4.66.1                   pypi_0    pypi
transformers              4.33.1                   pypi_0    pypi
typing_extensions         4.7.1           py310haa95532_0
tzdata                    2023c                h04d1e81_0
urllib3                   2.0.4                    pypi_0    pypi
vc                        14.2                 h21ff451_1
vs2015_runtime            14.27.29016          h5e58377_2
websockets                11.0.3                   pypi_0    pypi
wheel                     0.38.4          py310haa95532_0
win_inet_pton             1.1.0           py310haa95532_0
xz                        5.4.2                h8cc25b3_0
yarl                      1.9.2                    pypi_0    pypi
zlib                      1.2.13               h8cc25b3_0
zstd                      1.5.5                hd43e919_0

Python Shell 輸出

Python 3.10.9 | packaged by Anaconda, Inc. | (main, Mar  8 2023, 10:42:25) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.cuda.is_available())
True
TurboHK commented 1 year ago

問題以奇怪的方式解決了。只要將終端由 Windows Terminal 換為 Powershell 即可運行。 @fanqiNO1 感謝您的幫助!