英文:
CUDA available in notebook but not in VS code terminal - same conda environment
问题
在conda环境中安装了torch。在命令行中运行python并尝试检查CUDA可用性时,结果显示False。
然而,在使用Jupyter Notebook时,它显示CUDA可用。我正在使用相同的环境。GPU位于相同的本地Windows机器上。
import torch
torch.cuda.is_available()
> True
!which python
> /c/Users/b2bt/anaconda3/envs/stable-diffusion/python
我尝试创建一个新的conda环境来运行stable diffusion web界面。之前我在不同的环境中安装了torch并成功使用了GPU。我原本期望终端会显示CUDA可用,但奇怪的是它没有。
英文:
I have torch installed in a conda environment. When I run python in command line and try to check CUDA availability I get False as show below.
>>> import torch
>>> torch.cuda.is_available()
False
However, when I use jupyter notebook, it shows CUDA is available. I'm using the same environment. The GPU is on the same local Windows machine
import torch
torch.cuda.is_available()
> True
!which python
> /c/Users/b2bt/anaconda3/envs/stable-diffusion/python
I tried creating a new conda environment to run the stable diffusion web UI. I've installed torch previously in a different environment and have used it successfully with GPU. I was expecting the terminal to show CUDA available but strangely it doesn't.
答案1
得分: 2
这个问题可能是使用 pip install pytorch
安装包引起的。
解决方法:
打开官方网站,并搜索适合你环境的正确版本。
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
英文:
This problem may be caused by using pip install pytorch
to install package.
Solution:
Open the official website, and search for the correct version for your environment.
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
答案2
得分: 2
我遇到了和你一样的问题。我意识到没有安装pytorch。
所以,使用上面提到的pip3命令进行安装:
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
英文:
I had the same issue as you have. I realized pytorch was not installed.
So, installed in using pip3 command stated above:
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论