Recently, I tried to set up a Windows machine for development, focusing on Python, machine learning (PyTorch with CUDA), and web development (Node.js with NPM). Following is the summarization of some critical steps and relevant materials.
Later, I further set it up as a ssh
server that can be accessed by my laptop over the internet. If you are interested, please check this post.
In Windows, PowerShell is more powerful than the legacy cmd
shell in terms of system administration, configuration management, and perform administrative tasks.
Firstly, enter PowerShell in administrator mode and modify the execution policy to enable shell scripting:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
And then, as a preparation step, install Microsoft C++ Build Tools - Visual Studio and add the C++ build tools so that some useful build tools like cmake
is ready for use.
P.S. Without these build tools, some packages will not be able to install via pip
.
Install git
using winget
is very convenient:
winget install --id Git.Git -e --source winget
Let's configure its default user name and user email. Noted that when you push commit to GitHub, the email will be used to identify your GitHub account:
git config --global user.name <name>
git config --global user.email <email>
To authorize your operation on GitHub, you will also need to generate a ssh key:
ssh-keygen -t rsa -C "<email>"
And then you need to add it to your account: Settings > SSH and GPG keys > Add SSH Key. Fill the title as you like and paste the key with the content of the generated id_rsa.pub
(NOT id_rsa
!!). The content of id_rsa.pub
can be easily accessed from command line:
Get-Content ~/.ssh/id_rsa.pub
Install Anaconda.
It's worth noting that the latest version of the Anaconda installer seems no longer to provide the add anaconda path to environment variable option. Therefore it has to be settled manually...
On Windows 11: Settings -> search Edit the system environment variables -> Select Path
and click Edit
-> Click Add
and enter <anaconda install folder>\Scripts
P.S. The default installation folder of Anaconda is C:\ProgramData\anaconda3
.
conda
in PowerShellEnter PowerShell in administrator mode and run:
conda init powershell
After restarting the terminal, verify conda
with:
conda env list
conda activate base
Select the appropriate Python, CUDA, and PyTorch version based on the webpage below:
Select the corresponding driver according to the GPU model. For example, the Dell laptop of my team has a GeForce GTX 1660 Ti:
Download and install CUDA:
Verify installation:
nvcc -V
nvidia-smi
conda create -n pytorch python=3.10
conda activate pytorch
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
Verify installation:
python
>>> import torch
>>> torch.rand(5, 3)
>>> torch.cuda.is_available()
Download from Node.js's official site and install it following the prompts should get it done:
Restart the PowerShell and verify the installation:
node -v
npm -v
In case you encounter any issues:
Install Visual Studio Code
code
commandTo add code
command for launching VS Code from terminal to read files, remember to select the corresponding options during installation.
Press Ctrl + Enter + P
to trigger the command plate and enter Terminal: Select Default Profile
. In my case, I select PowerShell.