Import torch 出错
报错:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'torch'
首先输入: exit()
退出python
再下载输入:
conda install pytorch torchvision torchaudio cpuonly -c pytorch
接下来出现:
…
…
…
下面:点击此处
出现:
其实env_pytorch 目录在这
下面进入对应env_pytorch 环境分别输入以下三句话:
conda install ipython
conda install jupyter
python -m ipykernel install --user --name pytorch
三步完成之后:
出现新的jupyter
点击打开
点击此网址进入网页
输入运行即可。
But:这里是实心的,不能运行
然后再输入:
pip insatll pyzmq==19.0.2
然后重新打开并新建,会变成空心的:
进入环境
输入:conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
下载完成后,进入python 在输入import torch
!!!成功了!!!