You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/00-software-setup.md
+84-23Lines changed: 84 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,14 @@
1
1
# Setting Up Programming Environment
2
2
3
3
4
-
This page provides instructions for installing the required packages and their dependencies on a local computer or server.
5
4
5
+
## Using Personal Computer
6
6
7
-
## Install miniforge
7
+
8
+
This section provides instructions for installing the required packages and their dependencies on a local computer or server.
9
+
10
+
11
+
### Install miniforge
8
12
9
13
10
14
If you already have a preferred way to manage Python versions and libraries, you can stick to that. Otherwise, we recommend you to install Python3 and all required libraries using [Miniforge](https://conda-forge.org/download/), a free minimal installer for the package, dependency, and environment manager [Conda](https://docs.conda.io/en/latest/index.html).
@@ -17,10 +21,10 @@ $ conda --version
17
21
```
18
22
19
23
20
-
## Configure programming environment
24
+
###Configure programming environment
21
25
22
26
23
-
With Conda installed, run the command below to install required packages and depenencies (except PyTorch):
27
+
With Conda installed, open the **Anaconda Prompt terminal**, and run the command below to install required packages and depenencies (except PyTorch):
@@ -41,10 +45,10 @@ Remember to activate your programming environment each time before running code
41
45
:::
42
46
43
47
44
-
## Validate programming environment
48
+
###Validate programming environment
45
49
46
50
47
-
Once the programming environment is fully set up, open a new terminal (just as you should do each time before running code examples), activate the programming environment, and launch JupyterLab by running the command below.
51
+
Once the programming environment is fully set up, open a new **Anaconda Prompt terminal** (just as you should do each time before running code examples), activate the programming environment, and launch JupyterLab by running the command below:
48
52
```console
49
53
$ conda activate practical_machine_learning
50
54
@@ -86,22 +90,25 @@ You should see output similar to the figure below. The exact package versions ma
86
90
:::
87
91
88
92
89
-
If the code runs without errors, it means the packages are correctly installed and your programming environment is ready for use. If you encounter an error (*e.g.*, ``ModuleNotFoundError``), it indicates that a package may not have been installed properly. In that case, please double-check your programming environment setup or bring the issue to the on-boarding session for assistance.
93
+
If the code runs without errors, it means that all packages are correctly installed and your programming environment is ready to use.
90
94
91
95
92
96
::::{warning}
93
-
If you encounter an error like the one shown in the figure below, it usually means PyTorch is trying to load a DLL (such as fbgemm.dll), but one of its dependencies is missing or incompatible. The most common causes are a missing Microsoft Visual C++ runtime or a mismatch between the installed PyTorch build and your Python/OS environment.
97
+
For Windows OS users, you might encounter an error
98
+
(``ImportError: DLL load failed while importing _C: The specified procedure could not be found``) as described below.
99
+
94
100
:::{figure} ./env/pytorch_error.png
95
101
:align: center
96
102
:width: 80%
97
103
:::
98
104
99
-
To verify, you can open another Jupyter notebook and test PyTorch again. You should see output similar to the example below.
105
+
It is a very common Windows-specific PyTorch issue, and it means that the underlying C++/CUDA DLLs that torch depends on could not be loaded correctly.
100
106
101
-
:::{figure} ./env/pytorch_another_test.png
102
-
:align: center
103
-
:width: 80%
104
-
:::
107
+
You should reinstall the correct matching build via the command below.
@@ -115,40 +122,94 @@ If you are using VS Code, you can select the installed ``practical_machine_learn
115
122
:::
116
123
117
124
118
-
## (Optional) Setting Up PyTorch with GPU Support
125
+
126
+
### (Optional) Setting Up PyTorch with GPU Support
119
127
120
128
121
-
If your computer has a GPU, you can install PyTorch with GPU support. Below are step-by-step instructions to update the `practical_machine_learning` programming environment.
129
+
**For Windows OS users**, if your computer has a GPU card, you can install PyTorch with GPU support.
130
+
Below are step-by-step instructions to update the ``practical_machine_learning`` programming environment.
122
131
123
132
124
133
First check your CUDA version.
125
134
Open a terminal (Linux/macOS) or PowerShell (Windows) and run:
126
-
```shell
127
-
nvcc --version
135
+
```console
136
+
$ nvcc --version
128
137
```
129
138
If ``nvcc`` is not in your PATH, you can instead run ``nvidia-smi``.
139
+
```console
140
+
$ nvidia-smi
141
+
```
142
+
143
+
130
144
Here is the output from my Windows machine:
131
145
:::{figure} ./env/test-cuda-compiler-driver.png
132
146
:align: center
133
147
:width: 80%
134
148
:::
135
149
136
150
137
-
Second, install the required packages and libraries using conda (for CUDA 12.1):
Second, remove any CPU-only versions of PyTorch that may have been installed (for example, those coming from Conda’s defaults or conda-forge channels), and hten install an older, CUDA-compatible version of PyTorch directly using ``pip``.
152
+
Here ``cu121`` indicates the CUDA version (12.1) that the PyTorch build was compiled with.
You can also run all the code examples in tutorials using [Google Colab](https://colab.research.google.com/), a free cloud-based platform that provides Jupyter Notebook environments with preinstalled ML libraries.
181
+
182
+
183
+
### Download Jupyter Notebooks
184
+
185
+
186
+
- You can open each Jupyter Notebook (usually with the ``.ipynb`` extension) from [HERE](https://github.com/ENCCS/practical-machine-learning/tree/main/content/jupyter-notebooks), and then select **Download raw file** to save it locally.
187
+
- Alternatively, you can download the entire repository at [HERE](https://github.com/ENCCS/practical-machine-learning/tree/main) by clicking the green ``<> Code`` button and choosing **Download ZIP** file. After unzipping the downloaded ZIP file, you will find all Jupyter Notebooks in the directory **practical-machine-learning-main/content/jupyter-notebooks**.
188
+
189
+
190
+
### Upload Jupyter Notebooks to Google Drive
191
+
192
+
193
+
Sign in to your [Google Drive](https://workspace.google.com/intl/en-US/products/drive/), then upload the downloaded Jupyter Notebooks to a convenient folder.
194
+
You can simply drag and drop the files directly into Google Drive or use the option **New → File upload**.
195
+
196
+
197
+
### Open Jupyter Notebooks in Google Colab
198
+
199
+
200
+
Once uploaded, right-click the Jupyter Notebooks file in Google Drive and select **Open with → Google Colaboratory**.
201
+
This will launch the notebook in Google Colab, where you can view, edit, and run the code cells interactively.
202
+
203
+
204
+
### Connect to a Hosted Runtime
205
+
206
+
207
+
In Google Colab, go to the top-right corner and click **Connect** to link your notebook to a Google-hosted runtime environment.
208
+
If you need GPU or TPU acceleration, select **Runtime → Change runtime type**, then choose the desired hardware accelerator.
209
+
210
+
211
+
### Run the Code
212
+
213
+
214
+
After connecting, follow the instructions inside the Jupyter Notebooks.
215
+
You can run each cell individually by pressing **Shift** + **Enter**, or execute the entire notebook using **Runtime → Run all**.
0 commit comments