栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

ubuntu18.04瀹夎cuda10.1_ubuntu20.04瀹夎cuda10.1?

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

ubuntu18.04瀹夎cuda10.1_ubuntu20.04瀹夎cuda10.1?

最近学习pytorch,需要安装环境,我的cuda环境如下:

可以看到我的cuda 环境是11.5,然后在pytorch官网:https://pytorch.org/get-started/locally/

看到这里没有11.5,只有11.3,后来没办法直接安装先(需要安装anaconda环境)

pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113

安装以后出现如下,表示安装成功:

接着试了一下,看看有没有安装成功:

发现没有成功?
后来一想,应该要在anaconda环境下的python才行,然后:

cd /home/caizc/anaconda3/

Python 3.7.0 (default, Jun 28 2018, 13:15:42) 
[GCC 7.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
>>> exit()

果然成功了。

接着pycharm进行设置:
File->setting

在上面选择刚才anaconda中的python即可,因为在其它地方也安装了pytorch,所以位置非常重要。

测试:

import torch

def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    print_hi('PyCharm')
    print(torch.__version__)
    print('torch cuda:',torch.cuda.is_available())


OK 成功了

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/783489.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号