目录
1 需求
在离线计算机上配置pytorch-gpu环境,离线机平台windows7,线上平台winddow10
2 线上机环境
2.1 安装anaconda
1. 官网下载安装包Anaconda | Individual Edition
2. anaconda安装选项
2.1 pytorch-gpu虚拟环境
1. 配置国内镜像源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
# 这个是pytroch的源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
# 查看添加的镜像:
conda config --get channels
2. 创建pytorch-gpu环境
conda create -n pytorch python=3.6
conda activate pytorch
# 安装常用的机器学习包
conda install matplotlib scikit-learn pandas seaborn visdom
# pytorch环境
# 注意cudatoolkit的版本一定要和显卡驱动匹配,考虑到离线机,取两者低版本
# 注意删除官网推荐的参数 -f pytorch ,才会自动从国内镜像源下载
conda install pytorch torchvision cudatoolkit=9.2
# 离线机上matplotlib的图无法画出来,加装PyQt5
pip install PyQt5 PyQt5-tools -i https://pypi.tuna.tsinghua.edu.cn/simple/
3. 安装qt时出现LinkError
解决LinkError: post-link script failed for package defaults::qt-5.9.7-vc14h73c81de_0问题
参考github上这个问题的回答:https://github.com/ContinuumIO/anaconda-issues/issues/10949。
找到以下文件:
“…\Anaconda3\pkgs\qt-5.12.5-h7ef1ec2__0\Scripts.qt-post-link.bat”
在文件的 @echo off这一行下面加上这句:
set PATH=%PATH%;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;
再尝试安装就可以了。
————————————————
版权声明:本文为CSDN博主「Friday..」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/miaohang222/article/details/115342431
3 复制环境到离线机
3.1 anaconda和环境复制
1. 与线上机安装一致:一样的安装包和配置
2. 在..\anaconda\envs下的pytorch环境压缩复制到离线机并解压
3. 在pycharm中添加conda虚拟环境
3.2 PyQt5的bug
matplotlib无法画图,报错:no Qt platform plugin could be initialized问题的解决办法
1. 在环境中加装PyQt5
# 离线机上matplotlib的图无法画出来,加装PyQt5
pip install PyQt5 PyQt5-tools -i https://pypi.tuna.tsinghua.edu.cn/simple/
2. 设置环境变量 ,重启Pycharm
设置环境变量QT_QPA_PLATFORM_PLUGIN_PATH才能找到新版Qt的路径,QT_QPA_PLATFORM_PLUGIN_PATH的值指向PyQt5路径下Qt\plugins子目录。在老猿的机器中环境变量设置为:
.......\Anaconda3\Lib\site-packages\PyQt5\Qt5\plugins
————————————————
版权声明:本文为CSDN博主「LaoYuanPython」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/LaoYuanPython/article/details/108088134