Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
anubhavamd authored Jul 12, 2022
1 parent 10efbd3 commit 3ee3fa7
Showing 1 changed file with 83 additions and 52 deletions.
135 changes: 83 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -543,74 +543,96 @@ To install TensorFlow using the wheels package, follow these commands:
python3 –version
```

If the Python version is less than, <3.7, upgrade Python. Otherwise, skip this step and go to step 3.
If the Python version is less than, <3.7, upgrade Python. Otherwise, skip this step and go to step 3.

**Note** The supported Python versions are 3.7, 3.8, 3.9, and 3.10.
**Note** The supported Python versions are 3.7, 3.8, 3.9, and 3.10.

```
sudo apt-get install python3.7 # or python3.8 or python 3.9 or python 3.10
sudo apt-get install python3.7 # or python3.8 or python 3.9 or python 3.10
```

2. Set up multiple python versions using update-alternatives.

```
update-alternatives --query python3
sudo update-alternatives --install
/usr/bin/python3 python3 /usr/bin/python[version] [priority]
```

update-alternatives --query python3
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python[version] [priority]

**Note** Follow the instruction in step 2 for incompatible Python versions.

sudo update-alternatives --config python3

1. Follow the screen prompts and select the Python version installed in step 2.
**Note** Follow the instruction in step 2 for incompatible Python versions.

1. Install or upgrade PIP.
```
sudo update-alternatives --config python3
```

sudo apt install python3-pip
3. Follow the screen prompts and select the Python version installed in step 2.

To install PIP:
4. Install or upgrade PIP.

/usr/bin/python[version] -m pip install --upgrade pip
```
sudo apt install python3-pip
```

Upgrade PIP for Python version installed in step 2:
To install PIP:

sudo pip3 install --upgrade pip
```
/usr/bin/python[version] -m pip install --upgrade pip
```

1. Install Tensorflow.
Upgrade PIP for Python version installed in step 2:

/usr/bin/python[version] -m pip install --user tensorflow-rocm==[wheel-version] --upgrade
```
sudo pip3 install --upgrade pip
```

1. Install Tensorflow for the Python version as indicated in step 2. For a valid wheel version for a ROCm release, refer to the instructions below:
5. Install Tensorflow.

```
/usr/bin/python[version] -m pip install --user tensorflow-rocm==[wheel-version] --upgrade
```

sudo apt install rocm-libs rccl
6. Install Tensorflow for the Python version as indicated in step 2. For a valid wheel version for a ROCm release, refer to the instructions below:

1. Update protobuf to 3.19 or lower.
```
sudo apt install rocm-libs rccl
```

/usr/bin/python3.7 -m pip install protobuf=3.19.0
7. Update protobuf to 3.19 or lower.

sudo pip3 install tensorflow
```
/usr/bin/python3.7 -m pip install protobuf=3.19.0
sudo pip3 install tensorflow
```

1. Set the environment variable PYTHONPATH.
8. Set the environment variable PYTHONPATH.

export PYTHONPATH=&quot;./.local/lib/python[version]/site-packages:$PYTHONPATH&quot; #Use same python version as in step 2
```
export PYTHONPATH="./.local/lib/python[version]/site-packages:$PYTHONPATH" #Use same python version as in step 2
```

1. Install libraries.
9. Install libraries.

sudo apt install rocm-libs rccl
```
sudo apt install rocm-libs rccl
```

1. Test installation.
10. Test installation.

python3 -c &#39;import tensorflow&#39; 2\&gt; /dev/null &amp;&amp; echo &#39;Success&#39; || echo &#39;Failure&#39;
```
python3 -c 'import tensorflow' 2> /dev/null && echo 'Success' || echo 'Failure'
```

**Note** For details on tensorflow-rocm wheels and ROCm version compatibility, see:

_[https://github.com/ROCmSoftwarePlatform/tensorflow-upstream/blob/develop-upstream/rocm\_docs/tensorflow-rocm-release.md](https://github.com/ROCmSoftwarePlatform/tensorflow-upstream/blob/develop-upstream/rocm_docs/tensorflow-rocm-release.md)_
[https://github.com/ROCmSoftwarePlatform/tensorflow-upstream/blob/develop-upstream/rocm\_docs/tensorflow-rocm-release.md](https://github.com/ROCmSoftwarePlatform/tensorflow-upstream/blob/develop-upstream/rocm_docs/tensorflow-rocm-release.md)

### 3.2.2 Test the TensorFlow Installation

To test the installation of TensorFlow, run the container image as specified in the previous section - _[Installing TensorFlow](#_Installing_TensorFlow)_. Ensure you access the Python shell in the Docker container.
To test the installation of TensorFlow, run the container image as specified in the previous section - [Installing TensorFlow](#_Installing_TensorFlow). Ensure you access the Python shell in the Docker container.

#python3 -c &#39;import tensorflow&#39; 2\&gt; /dev/null &amp;&amp; echo &#39;Success&#39; || echo &#39;Failure&#39;
```
python3 -c 'import tensorflow' 2> /dev/null && echo ‘Success’ || echo ‘Failure’
```

### 3.2.3 Run a Basic TensorFlow Example

Expand All @@ -620,13 +642,16 @@ Follow these steps:

1. Clone the TensorFlow example repository.

#git clone https://github.com/anubhavamd/tensorflow\_mnist.git

1. Install the dependencies of the code and run the code.
```
#git clone https://github.com/anubhavamd/tensorflow\_mnist.git
```

#pip3 install requirement.txt
2. Install the dependencies of the code and run the code.

#python mnist\_tf.py
```
#pip3 install requirement.txt
#python mnist\_tf.py
```

# Chapter 4 Deep Learning Training

Expand All @@ -647,11 +672,9 @@ Training is different from Inference, particularly from the hardware perspective
| --- | --- |
| Training is measured in hours/days. | Inference is measured in minutes. |
| Training is generally run offline in a data-center or cloud setting. | Inference is done on edge devices. |
| The memory requirements for training are higher than inference due to the necessity of storing intermediate data, such as activations and error gradients.
|
|
| The memory requirements for training are higher than inference due to the necessity of storing intermediate data, such as activations and error gradients.| |
| Data for training is available on the disk before the training process and is generally large. The training performance is measured in how fast the data batches can be processed. | Inference data usually arrives stochastically, which may be batched to improve performance. Performance of inference is usually measured in throughput speed to process the batch of data and the delay in responding to the input (latency). |
| Different quantization data types are normally chosen between training (FP32, BF16) and inference (FP16, INT8). The computation hardware has different specializations on different datatypes, leading to improvement in performance if a faster datatype can be selected for the corresponding task. |
| Different quantization data types are normally chosen between training (FP32, BF16) and inference (FP16, INT8). The computation hardware has different specializations on different datatypes, leading to improvement in performance if a faster datatype can be selected for the corresponding task.|

### 4.1.1 Case Studies

Expand All @@ -669,23 +692,31 @@ This example is adapted from the PyTorch research hub page on Inception-v3 [3].1

Follow these steps:

1. Run the Pytorch ROCm-based Docker image, or refer to section 3.1.1_[Installing PyTorch](#_Installing_PyTorch)_ for setting up a PyTorch environment on ROCm.
1. Run the Pytorch ROCm-based Docker image, or refer to section 3.1.1 [Installing PyTorch](#_Installing_PyTorch) for setting up a PyTorch environment on ROCm.

docker run -it -v $HOME:/data --cap-add=SYS\_PTRACE --security-opt seccomp=unconfined --device=/dev/kfd --device=/dev/dri --group-add video --ipc=host --shm-size 8G rocm/pytorch:latest

1. Install the &quot;torchvision&quot; dependency in the Python installed on the container.
```
docker run -it -v $HOME:/data --cap-add=SYS\_PTRACE --security-opt
seccomp=unconfined --device=/dev/kfd --device=/dev/dri --group-add video
--ipc=host --shm-size 8G rocm/pytorch:latest
```

pip install --user git+https://github.com/pytorch/vision.git@8a2dc6f22ac4389ccba8859aa1e1cb14f1ee53db
2. Install the “torchvision” dependency in the Python installed on the container.

1. Run the Python shell start importing packages and libraries for model creation.
```
pip install --user git+https://github.com/pytorch/vision.git@8a2dc6f22ac4389ccba8859aa1e1cb14f1ee53db
```

import torch
3. Run the Python shell start importing packages and libraries for model creation.

import torchvision
```
import torch
import torchvision
```

1. Set the model in evaluation mode. Evaluation mode directs PyTorch to not store intermediate data, which would have been used in training.
4. Set the model in evaluation mode. Evaluation mode directs PyTorch to not store intermediate data, which would have been used in training.

model **=** torch.hub.load(&#39;pytorch/vision:v0.10.0&#39;, &#39;inception\_v3&#39;, pretrained **=** True)
```
model = torch.hub.load(&#39;pytorch/vision:v0.10.0&#39;, &#39;inception\_v3&#39;, pretrained **=** True)
model.eval()
Expand Down

0 comments on commit 3ee3fa7

Please sign in to comment.