cuda & pyinstall & cvs 使用记录

1.pip 换源

pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/

2.安装匹配cuda的pytorch

官网:PyTorch

pip3 install torch torchvision torchaudio

查看能否使用cuda:

import torch
torch.cuda.is_available()

获得以下反馈:

意思是cuda和pytorch版本不一致 

查看CUDA版本

cuda & pyinstall & cvs 使用记录_第1张图片

 继续去pytorch官网

cuda & pyinstall & cvs 使用记录_第2张图片

在新页面搜索cuda 10.2

 cuda & pyinstall & cvs 使用记录_第3张图片

获得安装指令

pip install torch==1.12.0+cu102 torchvision==0.13.0+cu102 torchaudio==0.12.0 --extra-index-url https://download.pytorch.org/whl/cu102

3.打包.py为.exe文件

安装pyinstaller

pip install pyinstaller

pyinstaller官方文档:pyinstaller

如果要打包单独的x.py(不依赖于自建的类或函数),直接运行

pyinstaller --onefile x.py

但是如果x.py调用了自己定义的其他.py文件或库的类或函数,运行上面这个命令会报错。

解决方法:分两步走

1.生成.spec文件

pyi-makespec -F ClickEveryDay.py

2.修改.spec文件

将需要调用的同目录.py加到x.py后,然后把文件夹类的添加进binaries。

cuda & pyinstall & cvs 使用记录_第4张图片

 修改后运行

 pyinstaller runMain.spec

4.MACOS安装cvs

安装homebrew:

 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

brew直接安装cvs:

brew install cvs

你可能感兴趣的:(python,linux,深度学习)