brainsteam.co.uk/brainsteam/content/posts/legacy/2020-02-02-pytorch-1-x-x-an...

36 lines
2.6 KiB
Markdown
Raw Normal View History

2020-12-28 11:39:11 +00:00
---
author: James
2023-07-09 11:34:44 +01:00
date: 2020-02-02 14:40:46+00:00
2020-12-28 11:39:11 +00:00
medium_post:
2023-07-09 11:34:44 +01:00
- O:11:"Medium_Post":11:{s:16:"author_image_url";s:69:"https://cdn-images-1.medium.com/fit/c/200/200/0*naYvMn9xdbL5qlkJ.jpeg";s:10:"author_url";s:30:"https://medium.com/@jamesravey";s:11:"byline_name";N;s:12:"byline_email";N;s:10:"cross_link";s:2:"no";s:2:"id";s:12:"8e038847a808";s:21:"follower_notification";s:3:"yes";s:7:"license";s:19:"all-rights-reserved";s:14:"publication_id";s:2:"-1";s:6:"status";s:6:"public";s:3:"url";s:98:"https://medium.com/@jamesravey/pytorch-1-x-x-and-pipenv-and-specific-versions-of-cuda-8e038847a808";}
post_meta:
- date
2020-12-28 11:39:11 +00:00
tags:
2023-07-09 11:34:44 +01:00
- developer
- projects
- python
- work
title: PyTorch 1.X.X and Pipenv and Specific versions of CUDA
type: posts
url: /2020/02/02/pytorch-1-x-x-and-pipenv-and-specific-versions-of-cuda/
2020-12-28 11:39:11 +00:00
---
2023-07-09 11:34:44 +01:00
2020-12-28 11:39:11 +00:00
I recently ran into an issue where the newest version of Torch (as of writing 1.4.0) requires a newer version of CUDA/Nvidia Drivers than I have installed.
Last time I tried to upgrade my CUDA version it took me several hours/days so I didn’t really want to have to spend lots of time on that.
As it happens PyTorch has an archive of compiled python whl objects for different combinations of Python version (3.5, 3.6, 3.7, 3.8 – heck even 2.X which is no longer officially supported), CUDA Version (9.2, 10.0, 10.1) and Torch version (from 0.1 to 1.4). You can specify which you want to install if you know the right incantation. The full index is available [here][1]
If you’re using pip and virtualenvs to manage your python environment you can just run:
<pre class="wp-block-preformatted" lang="shell">pip install torch==1.4.0+cu100 -f https://download.pytorch.org/whl/torch_stable.html </pre>
This will install torch 1.4.0 with cuda 10.0 support and it&#8217;ll work out which version of Python you&#8217;re running for you.
Now if you&#8217;re using Pipenv which tries to simplify virtualenv management and package versioning, you&#8217;ll quickly see that there is no way to run the above with `pipenv install`. Currently the only solution I can find is to manually run the above command prefixed with `pipenv run`
So far I&#8217;ve only found one other person who&#8217;s asked about this particular issue on [stackoverflow][2]. I&#8217;ve also [opened a github ticket][3] in the pipenv project. I am curious to know if anyone else has run into this issue or has a solution
[1]: https://download.pytorch.org/whl/torch_stable.html
[2]: https://stackoverflow.com/questions/59752559/how-to-specify-pytorch-cuda-version-in-pipenv
[3]: https://github.com/pypa/pipenv/issues/4121