用conda虚拟环境解决py+torch环境问题

通过conda创建虚拟环境并使用nb_conda在jupyter notebook中切换环境。遇到torch1.4+cu101安装错误,尝试了python3.6到3.8版本,均报错,而其他torch版本和CPU版本则正常。怀疑torch1.4+cu101安装包存在问题,conda安装能确保环境隔离。
摘要由CSDN通过智能技术生成

要事先安装wheel

pip install wheel
conda install nb_conda

安装nb_conda这样可以在shell切换虚拟环境启动jupyter notebook后切换到虚拟环境

 

创建虚拟环境

conda create -n python36 python=3.6
conda activate python36

加载后再pip安装torch1.4+cu101

所有版本torch 放在某个文件夹,比如桌面后

powershell切换到桌面安装

cd Desktop
pip install torch-1.4.0-cp36-cp36m-win_amd64.whl

 

进入jupyter,选择文件打开后,点kernel里切换服务,如果没有,那就powershell切换到虚拟环境

conda install ipykernel

再试一次

import torch
print (torch.__version__)
DLL load failed: 找不到指定的模块
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值