python - 在 setup.py 中使用 CUDA 安装 PyTorch
问题描述
我正在尝试在 install_requires 中使用 CUDA 指定 PyTorch。使用 pip 安装的命令是
pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio===0.8.0 -f https://download.pytorch.org/whl/torch_stable.html
我如何在 setup.py install_requires 中做到这一点?
解决方案
后来我也遇到了同样的问题,我修复了它,但是在setup.py
文件中使用它并且它有效,只需将这些行添加到您的setup.py
文件中即可。
"torch@https://download.pytorch.org/whl/cu111/torch-1.8.0%2Bcu111-cp37-cp37m-linux_x86_64.whl",
"torchvision@https://download.pytorch.org/whl/cu111/torchvision-0.9.0%2Bcu111-cp37-cp37m-linux_x86_64.wh",
"torchaudio@https://download.pytorch.org/whl/torchaudio-0.8.0-cp36-cp36m-linux_x86_64.whl"
如果您想要任何 MACOSX 或 Windows,所有这些都适用于 linux 版本,只需在每一行中更改 @ 之后的链接,您就可以从中获取所需版本的链接 https://download.pytorch.org/whl/torch_stable.html
推荐阅读
- php - Laravel:根据月份的周数计算整数值
- regex - 多个路径的 nginx 位置正则表达式但无效
- ruby - 使用数组值作为哈希键在 Ruby 中创建嵌套哈希
- arrays - MongoDB对深场的请求
- gensim - 在具有预训练模型的 gensim 中,wmdistance 运行良好,但 n_similarity 不是
- angular - `ngcc --properties es2015 浏览器模块主 --first-only --create-ivy-entry-points 上的角度错误
- python - 索引 R 与 Python
- ruby-on-rails - 如何不向客户端发送任何数据?
- focus - 听专注于选定的选项
- arrays - 创建嵌套 JSON 对象失败