Skip to content

Commit 5104366

Browse files
author
Marwan Mattar
authored
Merge pull request #445 from Unity-Technologies/docs-windowsinstructions
ML-Agents for Windows Instructions
2 parents 0e3b671 + 5b094fb commit 5104366

12 files changed

+194
-3
lines changed

docs/Installation-Windows.md

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
# Installing ML-Agents for Windows
2+
3+
ML-Agents supports Windows 10. While it might be possible to run ML-Agents using other versions of Windows, it has not been tested on other versions. Furthermore, ML-Agents has not been tested on a Windows VM such as Bootcamp or Parallels.
4+
5+
To use ML-Agents, you install Python and the required Python packages as outlined below. This guide also covers how set up GPU-based training (for advanced users). GPU-based training is not required for the v0.3 release of ML-Agents. However, training on a GPU might be required by future versions and features.
6+
7+
## Step 1: Install Python via Anaconda
8+
9+
<a href="https://www.anaconda.com/download/#windows" target="_blank">Download</a> and install Anaconda for Windows. By using Anaconda, you can manage separate environments for different distributions of Python. Python 3 is required as we no longer support Python 2. In this guide, we are using Python version 3.6 and Anaconda version 5.1 ([64-bit](https://repo.continuum.io/archive/Anaconda3-5.1.0-Windows-x86_64.exe) or [32-bit](https://repo.continuum.io/archive/Anaconda3-5.1.0-Windows-x86.exe) direct links).
10+
11+
<p align="center">
12+
<img src="images/anaconda_install.PNG"
13+
alt="Anaconda Install"
14+
width="500" border="10" />
15+
</p>
16+
17+
We recommend the default _advanced installation options_. However, select the options appropriate for your specific situation.
18+
19+
<p align="center">
20+
<img src="images/anaconda_default.PNG"
21+
alt="Anaconda Install"
22+
width="500" border="10" />
23+
</p>
24+
25+
After installation, you must open __Anaconda Navigator__ to finish the setup. From the Windows search bar, type _anaconda navigator_. You can close Anaconda Navigator after it opens.
26+
27+
## Step 2: Setup and Activate a New Conda Environment
28+
29+
You will create a new [Conda environment](https://conda.io/docs/) to be used with ML-Agents. This means that all the packages that you install are localized to just this environment. It will not affect any other installation of Python or other environments. Whenever you want to run ML-Agents, you will need activate this Conda environment.
30+
31+
To create a new Conda environment, open a new Anaconda Prompt (_Anaconda Prompt_ in the search bar) and type in the following command:
32+
33+
```
34+
conda create -n ml-agents python=3.6
35+
```
36+
37+
You may be asked to install new packages. Type `y` and press enter _(make sure you are connected to the internet)_. You must install these required packages. The new Conda environment is called ml-agents and uses Python version 3.6.
38+
39+
<p align="center">
40+
<img src="images/conda_new.PNG"
41+
alt="Anaconda Install"
42+
width="500" border="10" />
43+
</p>
44+
45+
To use this environment, you must activate it. _(To use this environment In the future, you can run the same command)_. In the same Anaconda Prompt, type in the following command:
46+
47+
```
48+
conda activate ml-agents
49+
```
50+
51+
You should see `(ml-agents)` prepended on the last line.
52+
53+
Next, install `tensorflow`. Install this package using `pip` - which is a package management system used to install Python packages. In the same Anaconda Prompt, type in the following command _(make sure you are connected to the internet)_:
54+
55+
```
56+
pip install tensorflow
57+
```
58+
59+
## Step 3: Install Required Python Packages
60+
61+
ML-Agents depends on a number of Python packages. Use `pip` to install these Python dependencies.
62+
63+
If you haven't already, clone the ML-Agents Github repository to your local computer. You can do this using Git ([download here](https://git-scm.com/download/win)) and running the following commands in an Anaconda Prompt _(if you open a new prompt, be sure to activate the ml-agents Conda environment by typing `activate ml-agents`)_:
64+
65+
```
66+
git clone [email protected]:Unity-Technologies/ml-agents.git
67+
```
68+
69+
If you don't want to use Git, you can always directly download all the files [here](https://github.com/Unity-Technologies/ml-agents/archive/master.zip).
70+
71+
In our example, the files are located in `C:\Downloads`. After you have either cloned or downloaded the files, from the Anaconda Prompt, change to the python directory inside the ML-agents directory:
72+
73+
```
74+
cd C:\Downloads\ml-agents\python
75+
```
76+
77+
Make sure you are connected to the internet and then type in the Anaconda Prompt:
78+
79+
```
80+
pip install .
81+
```
82+
83+
This will complete the installation of all the required Python packages to run ML-Agents.
84+
85+
## (Optional) GPU Training using ML-Agents
86+
87+
Not required to use v0.3 for ML-Agents. This is a guide for advanced users who want to train using GPUs. Additionally, you will need to check if your GPU is CUDA compatible. Please check Nvidia's page [here](https://developer.nvidia.com/cuda-gpus).
88+
89+
As of ML-Agents v0.3, only CUDA 8 and cuDNN 6 is supported.
90+
91+
## (Optional) Step 1: Install Nvidia CUDA toolkit
92+
93+
<a href="https://developer.nvidia.com/cuda-toolkit-archive" target="_blank">Download</a> and install the CUDA toolkit from Nvidia's archive. The toolkit includes GPU-accelerated libraries, debugging and optimization tools, a C/C++ compiler and a runtime library and is needed to run ML-Agents. In this guide, we are using version 8.0.61 ([direct link](https://developer.nvidia.com/compute/cuda/8.0/Prod2/network_installers/cuda_8.0.61_win10_network-exe)).
94+
95+
_Before installing, please make sure you __close any running instances of Unity or Visual Studio.___
96+
97+
Run the installer and select the Express option. Note the directory where you installed the CUDA toolkit. In this guide, we installed in the directory `C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0`
98+
99+
## (Optional) Step 2: Install Nvidia cuDNN library
100+
101+
<a href="https://developer.nvidia.com/cudnn" target="_blank">Download</a> and install the cuDNN library from Nvidia. cuDNN is is a GPU-accelerated library of primitives for deep neural networks. Before you can download, you will need to sign up for free to the Nvidia Developer Program.
102+
103+
<p align="center">
104+
<img src="images/cuDNN_membership_required.png"
105+
alt="cuDNN membership required"
106+
width="500" border="10" />
107+
</p>
108+
109+
Once you've signed up, go back to the cuDNN <a href="https://developer.nvidia.com/cudnn" target="_blank">downloads page</a>. You may or may not be asked to fill out a short survey. When you get to the list cuDNN releases, __make sure you are downloading the right version for the CUDA toolkit you installed in Step 1.__ In this guide, we are using version 6.0 for CUDA toolkit version 8.0 ([direct link](https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v6/prod/8.0_20170307/cudnn-8.0-windows10-x64-v6.0-zip)).
110+
111+
After you have downloaded the cuDNN files, you will need to extract the files into the CUDA toolkit directory. In the cuDNN zip file, there are three folders called `bin`, `include`, and `lib`.
112+
113+
<p align="center">
114+
<img src="images/cudnn_zip_files.PNG"
115+
alt="cuDNN zip files"
116+
width="500" border="10" />
117+
</p>
118+
119+
Copy these three folders into the CUDA toolkit directory. The CUDA toolkit directory is located at `C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0`
120+
121+
<p align="center">
122+
<img src="images/cuda_toolkit_directory.PNG"
123+
alt="cuda toolkit directory"
124+
width="500" border="10" />
125+
</p>
126+
127+
## (Optional) Step 3: Set Environment Variables
128+
129+
You will need to add one environment variable and two path variables.
130+
131+
To set the environment variable, type `environment variables` in the search bar (this can be reached by hitting the Windows key or the bottom left Windows button). You should see an option called __Edit the system environment variables__.
132+
133+
<p align="center">
134+
<img src="images/edit_env_var.png"
135+
alt="edit env variables"
136+
width="250" border="10" />
137+
</p>
138+
139+
From here, click the __Environment Variables__ button. Click __New__ to add a new system variable _(make sure you do this under __System variables__ and not User variables_.
140+
141+
<p align="center">
142+
<img src="images/new_system_variable.PNG"
143+
alt="new system variable"
144+
width="500" border="10" />
145+
</p>
146+
147+
For __Variable Name__, enter `CUDA_HOME`. For the variable value, put the directory location for the CUDA toolkit. In this guide, the directory location is `C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0`. Press __OK__ once.
148+
149+
<p align="center">
150+
<img src="images/system_variable_name_value.PNG"
151+
alt="system variable names and values"
152+
width="500" border="10" />
153+
</p>
154+
155+
To set the two path variables, inside the same __Environment Variables__ window and under the second box called __System Variables__, find a variable called `PATH` and click __Edit__. You will add two directories to the list. For this guide, the two entries would look like:
156+
157+
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64
158+
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\extras\CUPTI\libx64
159+
160+
Make sure to replace the relevant directory location with the one you have installed. _Please note that case sensitivity matters_.
161+
162+
<p align="center">
163+
<img src="images/path_variables.PNG"
164+
alt="Path variables"
165+
width="500" border="10" />
166+
</p>
167+
168+
## (Optional) Step 4: Install TensorFlow GPU
169+
Next, install `tensorflow-gpu` using `pip`. In an Anaconda Prompt with the Conda environment ml-agents activated, type in the following command _(make sure you are connected to the internet)_:
170+
171+
```
172+
pip install tensorflow-gpu
173+
```
174+
175+
Lastly, you should test to see if everything installed properly and that TensorFlow can identify your GPU. In the same Anaconda Prompt, type in the following command:
176+
177+
```
178+
python
179+
180+
import tensorflow as tf
181+
182+
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
183+
```
184+
185+
You should see something similar to:
186+
187+
```
188+
Found device 0 with properties ...
189+
```
190+
191+
## Acknowledgements
192+
193+
We would like to thank [Jason Weimann](https://unity3d.college/2017/10/25/machine-learning-in-unity3d-setting-up-the-environment-tensorflow-for-agentml-on-windows-10/) and [Nitish S. Mutha](http://blog.nitishmutha.com/tensorflow/2017/01/22/TensorFlow-with-gpu-for-windows.html) for writing the original articles which were used to create this guide.

docs/Installation.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ Some of the primary dependencies include:
3636

3737
### Windows Users
3838

39-
If you are a Windows user who is new to Python and TensorFlow, follow
40-
[this guide](https://unity3d.college/2017/10/25/machine-learning-in-unity3d-setting-up-the-environment-tensorflow-for-agentml-on-windows-10/)
41-
to set up your Python environment.
39+
If you are a Windows user who is new to Python and TensorFlow, follow [this guide](Installation-Windows.md) to set up your Python environment.
4240

4341
### Mac and Unix Users
4442

docs/images/anaconda_default.PNG

174 KB
Loading

docs/images/anaconda_install.PNG

159 KB
Loading

docs/images/conda_new.PNG

113 KB
Loading
90.8 KB
Loading
51.2 KB
Loading

docs/images/cudnn_zip_files.PNG

45.1 KB
Loading

docs/images/edit_env_var.png

40.5 KB
Loading
60.1 KB
Loading

0 commit comments

Comments
 (0)