# Environment Setup

### Check Python library version

Python library authors put the version number in `<module>.__version__`

```bash
python -c 'import keras; print(keras.__version__)'
```

### install Python package from "requirements.txt"

```bash
pip install -r requirements.txt
```

**requirements.txt**

{% code title="requirements.txt" %}

```
BeautifulSoup
Django==1.3
Fabric==1.2.0
Jinja2==2.5.5
PyYAML==3.09
Pygments==1.4
SQLAlchemy==0.7.1
South==0.7.3
amqplib==0.6.1
anyjson==0.3
...
```

{% endcode %}

###

## Anaconda

<https://www.anaconda.com/download/>

**Create Anaconda Virtural Environment**

> conda create --name **tensorflow** python=**3.5** **anaconda**

| Command           | Description                                               |
| ----------------- | --------------------------------------------------------- |
| --name tensorflow | Virtual Environment Name is "tensorflow"                  |
| python=3.5        | Python version is "3.5"                                   |
| anaconda          | Install Python library (e.g. Jupyter Notebook, NumPy ...) |

**Upgrade pip**

`python -m pip install --upgrade pip`

**Uninstall**

```bash
conda install -c anaconda anaconda-clean
anaconda-clean --yes
```

#### &#x20;<a href="#ffb9" id="ffb9"></a>

### 存與依據環境檔創建環境

想像在一台電腦以conda建立了一個環境開發某專案，如何讓程式在其他人的電腦上有一樣的環境能重現並開發該專案呢？這時只要使用`conda env export > environment.yaml`記錄下環境的相關資訊檔environment.yaml，將它放到另一台電腦上然後以`conda env create -f environment.yaml`載入並建立該環境，如此一來就能在另一台電腦重現了環境並開發該專案了。

* **儲存環境** `conda env export > environment.yaml`
* **依據環境檔創建環境** `conda env create -f environment.yaml`

```bash
conda env export > environment.yaml     # in PC A
conda env create -f environment.yaml    # in PC B
```

**Fixing Jupyter notebook  kernel error**

```bash
python -m ipykernel install --user
```

or

```bash
python -m ipykernel install 
```

### Tensorflow

Installation

```bash
pip install --ignore-installed --upgrade tensorflow
```

```bash
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.7.0-py3-none-any.whl
```

check version

```python
import tensorflow as tf; 
print(tf.__version__)
```

###

### Keras

**Installation**

```bash
pip install keras
```

**Alternate Installation**

```bash
conda install -c anaconda theano
conda install -c conda-forge tensorflow 
conda install -c conda-forge keras
```

**Change Keras backend**

```
set "KERAS_BACKEND=tensorflow"
```

```
set "KERAS_BACKEND=theano"
```

C:\Users\Ryan\AppData\Local\conda\conda\envs\tensorflow\etc\conda\activate.d\keras\_activate.bat

<https://github.com/ContinuumIO/anaconda-issues/issues/1735>

<https://keras.io/backend/>

## CUDA on ML machines

### Install CUDA on Linux-based ML machines

**One Liner Install**

{% embed url="<http://cuda-bootstrap.com/>" %}

## Hardware Requirement

### 如何配置一台适用于深度学习的工作站？

<https://www.zhihu.com/question/33996159>

{% embed url="<https://medium.com/the-mission/how-to-build-the-perfect-deep-learning-computer-and-save-thousands-of-dollars-9ec3b2eb4ce2>" %}

{% embed url="<https://medium.com/the-mission/why-building-your-own-deep-learning-computer-is-10x-cheaper-than-aws-b1c91b55ce8c>" %}

##
