TensorFlow: Difference between revisions
Jump to navigation
Jump to search
(70 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
==Install== | ==Install== | ||
{| | |||
| valign="top" colspan="2" | | |||
<syntaxhighlight lang="bash"> | |||
export PATH="/usr/local/cuda-12.0/bin:${PATH}" | |||
export LD_LIBRARY_PATH="/usr/local/cuda-12.0/lib64:${LD_LIBRARY_PATH}" | |||
# ls -lah /usr/local/cuda-12.0/lib64/|grep libnvinfer | |||
# ls -lah /usr/local/cuda-12.0/lib64/|grep libcudart | |||
sudo update-alternatives --config cuda | |||
nvcc --version | |||
</syntaxhighlight> | |||
|- | |||
| colspan="2" | | |||
---- | |||
|- | |||
| valign="top" | | |||
<syntaxhighlight lang="bash"> | |||
sudo apt udpate | |||
sudo apt install python3-dev python3-pip python3-venv | |||
# sudo apt install nvidia-cuda-toolkit | |||
</syntaxhighlight> | |||
| valign="top" | | |||
<syntaxhighlight lang="bash"> | |||
apk update | |||
apk add bash gcc musl-dev python3 python3-dev py3-pip libxslt-dev libxml2-dev | |||
# apk add nvidia-cuda-toolkit | |||
</syntaxhighlight> | |||
|- | |||
| colspan="2" | | |||
---- | |||
|- | |||
| valign="top" | | |||
<syntaxhighlight lang="bash"> | |||
python3 -m venv ~/.venv/tensorflow --prompt="TensorFlow" | |||
source ~/.venv/tensorflow/bin/activate | |||
pip install --upgrade pip | |||
</syntaxhighlight> | |||
| valign="top" | | |||
<syntaxhighlight lang="bash"> | |||
python3 -m venv ~/.venv/tensorflow --prompt="TensorFlow" | |||
source ~/.venv/tensorflow/bin/activate | |||
pip install --upgrade pip | |||
</syntaxhighlight> | |||
|- | |||
| colspan="2" | | |||
---- | |||
|- | |||
| valign="top" colspan="2" | | |||
<syntaxhighlight lang="bash"> | |||
# export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 | |||
# pip install jep ads gspread | |||
</syntaxhighlight> | |||
|- | |||
| colspan="2" | | |||
---- | |||
|- | |||
| valign="top" | | |||
<syntaxhighlight lang="bash"> | |||
pip install tensorflow | |||
pip show tensorflow | |||
pip install tensorrt | |||
pip show tensorrt | |||
</syntaxhighlight> | |||
| valign="top" | | |||
<syntaxhighlight lang="bash"> | |||
pip install tensorflow[and-cuda] | |||
pip install tensorflow | |||
pip show tensorflow | |||
pip install tensorrt | |||
pip show tensorrt | |||
</syntaxhighlight> | |||
|- | |||
| colspan="2" | | |||
---- | |||
|- | |||
| valign="top" colspan="2" | | |||
<syntaxhighlight lang="bash"> | |||
python -c 'import tensorflow as tf; print(tf.__version__)' | |||
python -c 'import tensorflow as tf; print(tf.test.is_gpu_available())' | |||
python -c 'import tensorflow as tf; print("Tensorflow Version: ", tf.__version__)' | |||
python -c 'import tensorflow as tf; print(tf.config.list_physical_devices("GPU"))' | |||
python -c 'import tensorflow as tf; print(tf.sysconfig.get_build_info()["cudnn_version"])' | |||
pip uninstall tensorflow | |||
</syntaxhighlight> | |||
|} | |||
==CUDA Toolkit== | |||
'''verify cuda-capable gpu:''' | |||
cat /proc/driver/nvidia/version | |||
apt search nvidia-headless* | |||
apt search nvidia-driver-* | |||
ubuntu-drivers devices | |||
lspci | grep -i nvidia | |||
lsmod | grep -i nvidia | |||
lspci | grep -e VGA | |||
lspci | grep VGA | |||
nvcc --version | |||
dkms status | |||
nvidia-smi | |||
<syntaxhighlight lang="bash"> | |||
curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub\ | |||
| sudo gpg --dearmor -o /usr/share/keyrings/cuda-archive-keyring.gpg | |||
cat << EOF | sudo tee /etc/apt/sources.list.d/cuda-ubuntu2204-x86_64.list >/dev/null | |||
deb [arch=$(dpkg --print-architecture)\ | |||
signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg]\ | |||
https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ / | |||
EOF | |||
sudo apt install cuda | |||
sudo apt install cuda-drivers | |||
</syntaxhighlight> | |||
'''Or:''' | |||
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb | |||
sudo dpkg -i cuda-keyring_1.0-1_all.deb | |||
sudo apt update | |||
sudo apt install cuda | |||
sudo apt install cuda-drivers | |||
==Reinstall Nvidia== | |||
sudo apt update && sudo apt list --upgradable && sudo apt upgrade | |||
sudo /usr/local/cuda-X.Y/bin/cuda-uninstall | |||
sudo apt autoremove nvidia* --purge | |||
sudo /usr/bin/nvidia-uninstall | |||
nvidia-detector | |||
lspci | grep -e VGA | |||
ubuntu-drivers devices | |||
sudo ubuntu-drivers autoinstall | |||
sudo apt install nvidia-driver-525 cuda | |||
==Knowledge== | |||
{| | |||
| valign="top" | | |||
<syntaxhighlight lang="bash"> | |||
python3 -m venv .venv --prompt="TensorFlow" | |||
# source .venv/bin/activate | |||
# (academia) $ | |||
</syntaxhighlight> | |||
| valign="top" | | |||
<syntaxhighlight lang="bash"> | |||
python3 -m venv .venv --prompt="TensorFlow" | |||
# source .venv/bin/activate | |||
# (molecule) $ | |||
</syntaxhighlight> | |||
| valign="top" | | |||
<source lang="PowerShell"> | |||
python -m venv .venv --prompt="TensorFlow" | |||
# .venv\Scripts\activate | |||
# (molecule) PS> | |||
</syntaxhighlight> | |||
|- | |||
| colspan="3" | | |||
---- | |||
|- | |||
| valign="top" | | |||
apk list --installed|grep ^bash | |||
apk list --installed|grep bash | |||
apk add gcc | |||
| valign="top" | | |||
apk search | grep ^bash | |||
apk search | grep bash | |||
apk add g++ | |||
| valign="top" | | |||
apk info --contents bash | |||
apk info --rdepends bash | |||
apk add libc6-compat | |||
|- | |||
| colspan="3" | | |||
---- | |||
|- | |||
| valign="top" | | |||
sudo apt search nvidia-cuda-toolkit | |||
sudo apt install nvidia-cuda-toolkit | |||
| valign="top" | | |||
sudo find / -name 'libcudart.so*' | |||
sudo chmod a+r /usr/lib/x86_64-linux-gnu/libcuda* | |||
| valign="top" | | |||
nvidia-smi | |||
sudo apt install cuda | |||
|- | |||
| colspan="3" | | |||
---- | |||
|- | |||
| valign="top" | | |||
'''Installation :''' | |||
driver » | |||
driver & cuda » | |||
'''Installation :''' | |||
driver » | |||
driver & cuda » | |||
'''Installation :''' | |||
driver » | |||
driver & cuda » | |||
| valign="top" | | |||
'''Proprietary:''' | |||
sudo apt install nvidia-driver-510 | |||
sudo apt install nvidia-driver-510 cuda | |||
'''Proprietary:''' | |||
sudo apt install nvidia-driver-525 | |||
sudo apt install nvidia-driver-525 cuda | |||
'''Proprietary:''' | |||
sudo apt install nvidia-headless-525 | |||
sudo apt install nvidia-headless-525 cuda | |||
| valign="top" | | |||
'''OpenSource:''' | |||
sudo apt install nvidia-driver-510-open | |||
sudo apt install nvidia-driver-510-open cuda | |||
'''OpenSource:''' | |||
sudo apt install nvidia-driver-525-open | |||
sudo apt install nvidia-driver-525-open cuda | |||
'''OpenSource:''' | |||
sudo apt install nvidia-headless-525-open | |||
sudo apt install nvidia-headless-525-open cuda | |||
|- | |||
| colspan="3" | | |||
---- | |||
|- | |||
| colspan="2" | | |||
'''generic''' | |||
sudo apt install linux-modules-nvidia-510-5.15.0-60-generic | |||
sudo apt install linux-modules-nvidia-525-5.15.0-60-generic | |||
'''nvidia''' | |||
sudo apt install linux-modules-nvidia-510-5.15.0-1015-nvidia | |||
sudo apt install linux-modules-nvidia-525-5.15.0-1015-nvidia | |||
| valign="top" | | |||
'''purge nvidia driver''' | |||
sudo apt remove --purge '^nvidia-.*' | |||
sudo apt remove --purge '^libnvidia-.*' | |||
sudo apt remove --purge '^cuda-.*' | |||
'''reinstall linux kernel''' | |||
sudo apt install linux-headers-$(uname -r) | |||
|} | |||
==References== | ==References== | ||
Line 17: | Line 286: | ||
|valign='top'| | |valign='top'| | ||
* [[Academia JavaEE Workspace in Raspbian]] | |||
* [[Academia JavaEE Workspace in Ubuntu]] | |||
* [[Academia JavaEE Workspace in MacOS]] | |||
* [[VS Code on iPad Pro]] | |||
* [https://www.tensorflow.org/install Install TensorFlow] | * [https://www.tensorflow.org/install Install TensorFlow] | ||
* [[VSCode]] | |||
* [[Hadoop]] | * [[Hadoop]] | ||
* [[Ansible]] | |||
* [[Docker]] | |||
* [[Spark]] | * [[Spark]] | ||
|valign='top'| | |valign='top'| | ||
* [https://stackoverflow.com/questions/70967651/ Could not load dynamic library <code>libcudart.so.11.0</code>] | |||
* [https://stackoverflow.com/questions/64193633/ Could not load dynamic library <code>libcublas.so.10</code>] | |||
* [https://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html CUDA Installation Guide for Windows] | |||
* [https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=22.04&target_type=deb_network Tensorflow » CUDA Toolkit » Ubuntu] | |||
* [https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/dockerfiles Tensorflow » Dockerfile » Ubuntu] | |||
* [https://github.com/pgadmin-org/pgadmin4/blob/master/Dockerfile PgAdmin 4 » Dockerfile » Alpine] | |||
* [https://github.com/better/alpine-tensorflow/blob/master/Dockerfile Tensorflow » Dockerfile » Alpine] | |||
* [https://stackoverflow.com/questions/172587/ Difference between g++ & gcc] | |||
* [https://stackoverflow.com/questions/50897640/ Python 3 Virtual Env & Docker] | |||
* [[Linux Containers]] | |||
|- | |- | ||
Line 28: | Line 314: | ||
|- | |- | ||
|valign='top'| | |valign='top'| | ||
* [https://stackoverflow.com/questions/43022843/ Nvidia » NVML: Driver/library version mismatch] | |||
* [https://askubuntu.com/questions/1084476/ <code>xrandr</code> Not Showing All Ports & Resolutions] | |||
* [https://askubuntu.com/questions/885610/ <code>nvcc</code> Environment variable or path setting] | |||
* [https://medium.com/geekculture/installing-cudnn-and-cuda-toolkit-on-ubuntu-20-04-for-machine-learning-tasks-f41985fcf9b2 Nvidia » Installing cuDNN and CUDA Toolkit] | |||
* [https://www.linuxcapable.com/install-nvidia-drivers-on-ubuntu-linux/ Nvidia » Install Drivers on Ubuntu 22.04] | |||
* [https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html Nvidia » CUDA Installation Guide] | |||
* [https://forums.developer.nvidia.com/t/nvidia-smi-has-failed-because-it-couldnt-communicate-with-the-nvidia-driver-make-sure-that-the-latest-nvidia-driver-is-installed-and-running/197141/6 <code>nvidia-smi</code> has failed] | |||
* [https://developer.nvidia.com/cudnn Nvidia » cuDNN] | |||
* [[OpenGL]] | |||
* [[PyEnv]] | |||
* [[Bazel]] | |||
|valign='top'| | |valign='top'| |
Latest revision as of 01:18, 3 June 2024
Install
export PATH="/usr/local/cuda-12.0/bin:${PATH}"
export LD_LIBRARY_PATH="/usr/local/cuda-12.0/lib64:${LD_LIBRARY_PATH}"
# ls -lah /usr/local/cuda-12.0/lib64/|grep libnvinfer
# ls -lah /usr/local/cuda-12.0/lib64/|grep libcudart
sudo update-alternatives --config cuda
nvcc --version
| |
| |
sudo apt udpate
sudo apt install python3-dev python3-pip python3-venv
# sudo apt install nvidia-cuda-toolkit
|
apk update
apk add bash gcc musl-dev python3 python3-dev py3-pip libxslt-dev libxml2-dev
# apk add nvidia-cuda-toolkit
|
| |
python3 -m venv ~/.venv/tensorflow --prompt="TensorFlow"
source ~/.venv/tensorflow/bin/activate
pip install --upgrade pip
|
python3 -m venv ~/.venv/tensorflow --prompt="TensorFlow"
source ~/.venv/tensorflow/bin/activate
pip install --upgrade pip
|
| |
# export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
# pip install jep ads gspread
| |
| |
pip install tensorflow
pip show tensorflow
pip install tensorrt
pip show tensorrt
|
pip install tensorflow[and-cuda]
pip install tensorflow
pip show tensorflow
pip install tensorrt
pip show tensorrt
|
| |
python -c 'import tensorflow as tf; print(tf.__version__)'
python -c 'import tensorflow as tf; print(tf.test.is_gpu_available())'
python -c 'import tensorflow as tf; print("Tensorflow Version: ", tf.__version__)'
python -c 'import tensorflow as tf; print(tf.config.list_physical_devices("GPU"))'
python -c 'import tensorflow as tf; print(tf.sysconfig.get_build_info()["cudnn_version"])'
pip uninstall tensorflow
|
CUDA Toolkit
verify cuda-capable gpu: cat /proc/driver/nvidia/version apt search nvidia-headless* apt search nvidia-driver-* ubuntu-drivers devices lspci | grep -i nvidia lsmod | grep -i nvidia lspci | grep -e VGA lspci | grep VGA nvcc --version dkms status nvidia-smi
curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub\
| sudo gpg --dearmor -o /usr/share/keyrings/cuda-archive-keyring.gpg
cat << EOF | sudo tee /etc/apt/sources.list.d/cuda-ubuntu2204-x86_64.list >/dev/null
deb [arch=$(dpkg --print-architecture)\
signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg]\
https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /
EOF
sudo apt install cuda
sudo apt install cuda-drivers
Or: wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb sudo dpkg -i cuda-keyring_1.0-1_all.deb sudo apt update sudo apt install cuda sudo apt install cuda-drivers
Reinstall Nvidia
sudo apt update && sudo apt list --upgradable && sudo apt upgrade sudo /usr/local/cuda-X.Y/bin/cuda-uninstall sudo apt autoremove nvidia* --purge sudo /usr/bin/nvidia-uninstall
nvidia-detector lspci | grep -e VGA ubuntu-drivers devices sudo ubuntu-drivers autoinstall sudo apt install nvidia-driver-525 cuda
Knowledge
python3 -m venv .venv --prompt="TensorFlow"
# source .venv/bin/activate
# (academia) $
|
python3 -m venv .venv --prompt="TensorFlow"
# source .venv/bin/activate
# (molecule) $
|
<source lang="PowerShell"> python -m venv .venv --prompt="TensorFlow"
</syntaxhighlight> |
| ||
apk list --installed|grep ^bash apk list --installed|grep bash apk add gcc |
apk search | grep ^bash apk search | grep bash apk add g++ |
apk info --contents bash apk info --rdepends bash apk add libc6-compat |
| ||
sudo apt search nvidia-cuda-toolkit sudo apt install nvidia-cuda-toolkit |
sudo find / -name 'libcudart.so*' sudo chmod a+r /usr/lib/x86_64-linux-gnu/libcuda* |
nvidia-smi sudo apt install cuda |
| ||
Installation : driver » driver & cuda » Installation : driver » driver & cuda » Installation : driver » driver & cuda » |
Proprietary: sudo apt install nvidia-driver-510 sudo apt install nvidia-driver-510 cuda Proprietary: sudo apt install nvidia-driver-525 sudo apt install nvidia-driver-525 cuda Proprietary: sudo apt install nvidia-headless-525 sudo apt install nvidia-headless-525 cuda |
OpenSource: sudo apt install nvidia-driver-510-open sudo apt install nvidia-driver-510-open cuda OpenSource: sudo apt install nvidia-driver-525-open sudo apt install nvidia-driver-525-open cuda OpenSource: sudo apt install nvidia-headless-525-open sudo apt install nvidia-headless-525-open cuda |
| ||
generic sudo apt install linux-modules-nvidia-510-5.15.0-60-generic sudo apt install linux-modules-nvidia-525-5.15.0-60-generic nvidia sudo apt install linux-modules-nvidia-510-5.15.0-1015-nvidia sudo apt install linux-modules-nvidia-525-5.15.0-1015-nvidia |
purge nvidia driver sudo apt remove --purge '^nvidia-.*' sudo apt remove --purge '^libnvidia-.*' sudo apt remove --purge '^cuda-.*' reinstall linux kernel sudo apt install linux-headers-$(uname -r) |