Setup
Here's a guide for installing the project necessities, with separate tutorials for Windows and macOS.
Python Installation
Windows
1. Install Git
Choose one of the following methods:
-
Using winget tool in PowerShell or Command Prompt (requires terminal restart afterwards to take effect):
-
Or download the standalone installer from https://git-scm.com/download/win
2. Navigate to Project Folder
3. Check Installed Python Versions
To see which Python versions are installed on your system, run:
4. Create a Virtual Environment
- If Python 3.11 is installed along with other versions:
- If only Python 3.11 is installed:
5. Resolve Execution Policy Error
If you encounter an "about_Execution_Policies" error, run this command and retry step 4.:
6. Activate the Virtual Environment
7. Install Requirements
macOS
1. Install Git
Choose one of the following methods:
-
Using Homebrew:
-
Or choose another installation method from https://git-scm.com/download/mac
2. Navigate to Project Folder
3. Create a Virtual Environment
- For Python 3.11 (replace with your desired version if different):
- If you want to use the default Python 3 version:
4. Activate the Virtual Environment
5. Install Requirements
MATLAB Installation
This is how to set up Python for MATLAB.
1. Download Python 3.11.9
- Download from the official site (DO NOT download from MS Store):
- Python 3.11.9 for Windows (amd64)
- During installation, ensure you check the box for "Add python.exe to PATH".
2. Navigate to the MATLAB Project Folder via Windows Command Prompt
3. Check Installed Python Versions
4. Create a Virtual Environment
- Make a virtual environment to store Python modules by typing:
- If multiple Python versions are installed, use:
- If only Python 3.11 is installed, use:
5. Activate the Virtual Environment
- Activate the virtual environment via:
6. Install Required Packages
- Install the necessary packages with CUDA support into the new virtual environment:
7. Set the Python Environment in MATLAB
- In MATLAB console, specify the Python environment:
- The result should look like this: ```matlab ans =
PythonEnvironment with properties:
Version: "3.11"
Executable: "project_folder\.venv\Scripts\pythonw.exe"
Library: "C:\Users\user\AppData\Local\Programs\Python\Python311\python311.dll"
Home: "project_folder\.venv\Scripts\.venv"
Status: NotLoaded
ExecutionMode: InProcess
8. Restart MATLAB (if necessary)
- check if pyenv is set correctly in MATLAB console
Troubleshooting
For any of the installation steps above, you may need to uninstall the previous installation. Sometimes PyTorch cannot make use of CUDA due to incompatibility.
First option - Uninstall
pip uninstall torch torchvision
pip cache purge
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
Second option - Remove Virtual Environment
- Remove the directory recursively
- Restart from step Python Step 4 or MATLAB Step 4