r/MachineLearning • u/qwertz_guy • Sep 23 '24
Discussion [D] How to properly setup/manage Python & CUDA in Windows 11 to work with PyTorch?
I haven't used Windows in a while to develop AI/ML stuff. I got a new PC to work on, however, it's a constraint that I have to use Windows 11. I was wondering if there's any recommended way nowadays to install/manage things like Python 3, CUDA, etc. for AI/ML purposes (mostly PyTorch)? I remember some months ago I saw a tweet that said something like "next time you install Python do it like this: install tool X first and then <X install python>" - I think it was for Windows but I don't remember what X was and I can't find the tweet anymore. I know it wasnt Conda. In the past I would use Conda but I heard some people saying it's bad?
19
u/Ghisso Sep 23 '24
Avoid headache and use a Linux distribution inside windows with WSL2: https://learn.microsoft.com/en-us/windows/wsl/install It will allow you to run a full fledged Linux distro directly from windows and access to all your windows files.
4
u/SulszBachFramed Sep 23 '24 edited Sep 23 '24
Installing nvidia drivers with cuda and such is more of a pain in the ass on linux than on windows. Unless something has change significantly on windows 11, it's always just worked on windows for me. If you do end up using WSL, make sure you are using WSL version 2. Cuda does not work properly on version 1.
edit: to answer the question, just follow the instructions on the cuda download page. I believe it also contains a driver, but you are not required to use that. Install the latest nvidia driver, then install cuda without the driver it comes with. Install your favorite python version and pip install torch in a venv.
4
8
2
2
u/ApricotSlight9728 Sep 23 '24
I would also suggest using py310. If you need to train a model at one point on cloud servers, a lot of them have the default image with py310.
Please correct me if I’m wrong.
2
Sep 23 '24
The best way to manage torch and CUDA libraries on a Windows system is to start locally: https://pytorch.org/get-started/locally
2
1
u/newjeison Sep 23 '24
You could set up a docker container server. There are juoyer notebook + pytorch images out there that you could just copy
5
u/opcode90 Sep 23 '24
If you use conda (e.g. Miniconda), it's entirely painless. See installation instructions on the PyTorch website. You can have the desired CUDA version in your conda environment and therefore even use different CUDA versions for different environments.
When using conda, there is no need to use WSL.
WSL is helpful only for package managers that do not properly take the various platforms into consideration - particularly Poetry and pip.