CPU和GPU平台的Pytorch的需求。

发布于 2025-02-09 15:38:47 字数 463 浏览 2 评论 0原文

我正在尝试创建一个unignts.txt以使用pytorch,但希望它可以在GPU和非GPU平台上使用。

我在Linux GPU系统上做类似的操作:

--find-links https://download.pytorch.org/whl/cu113/torch_stable.html

torch==1.10.2+cu113
torchvision==0.11.3+cu113
pytorch-lightning==1.5.10

这可以正常工作并且安装了软件包,并且可以使用启用GPU的Pytorch。

我想知道如何对Mac和Non GPU用户进行修改,以安装torchtorchvision的非CUDA软件包?我需要维护单独的sumplions.txt文件吗?

I am trying to create a requirements.txt to use pytorch but would like it to work on both GPU and non-GPU platforms.

I do something like on my Linux GPU system:

--find-links https://download.pytorch.org/whl/cu113/torch_stable.html

torch==1.10.2+cu113
torchvision==0.11.3+cu113
pytorch-lightning==1.5.10

This works fine and the packages are installed and I can use the GPU-enabled pytorch.

I wonder how I can modify this for the mac and non GPU users to install the non cuda package for torch and torchvision? Do I need to maintain separate requirements.txt files?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

世界和平 2025-02-16 15:38:47

2024年2月更新

检查 https://pytorch.org/ 。您会看到“ CUDA在MacOS上不可用,请使用默认软件包”。但是,您仍然可以通过安装 mps来获得性能提升(这将取决于您的硬件) Pytorch的加速版本:

# MPS acceleration is available on MacOS 12.3+
pip3 install torch torchvision torchaudio

可以在此处生成此命令: https://pytorch.org/

”在此处描述“

,为了在不同平台上安装不同的火炬版本,您可以在sumplions.txt中使用有条件的版本

# for CUDA 11.8 torch on Linux
--index-url https://download.pytorch.org/whl/cu118; sys_platform == "linux"
torch; sys_platform == "linux"
torchvision; sys_platform == "linux"
pytorch-lightning; sys_platform == "linux"

# for MPS accelerated torch on Mac
torch; sys_platform == "darwin"
torchvision; sys_platform == "darwin"
pytorch-lightning; sys_platform == "darwin"

。 MacOS上的加速版

February 2024 update

Check https://pytorch.org/. You will see that "CUDA is not available on MacOS, please use default package". However, you can still get performance boosts (this will depend on your hardware) by installing the MPS accelerated version of pytorch by:

# MPS acceleration is available on MacOS 12.3+
pip3 install torch torchvision torchaudio

This command can be generated here: https://pytorch.org/

enter image description here

And in order to install different Torch versions on different platforms you can use conditionals in your requirements.txt like this

# for CUDA 11.8 torch on Linux
--index-url https://download.pytorch.org/whl/cu118; sys_platform == "linux"
torch; sys_platform == "linux"
torchvision; sys_platform == "linux"
pytorch-lightning; sys_platform == "linux"

# for MPS accelerated torch on Mac
torch; sys_platform == "darwin"
torchvision; sys_platform == "darwin"
pytorch-lightning; sys_platform == "darwin"

This will install CUDA enabled torch and torchvision on Linux but the MPS accelerated version of them on MacOS

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文