TensorFlow is an open-source library for creating and training neural networks by Google.
It can be installed into Blender using the pip package installer.
Before installation, make sure your system meets the minimum requirements:
- Blender must be version 2.80 or older (the minimum required Python version in Blender is 3.7)
- Your operating system must be:
- Windows 7 (x64) or older
- Ubuntu 16.04 (x64) or older
- MacOS 10.12.6 (x64) or older
For installation under Windows, you may need to install MS Visual C ++ Redistributable for Visual Studio
To install TensorFlow into Blender, we can use the script for installing Python packages with pip, specifying “tensorflow” in the package name.
python_exe = os.path.join(sys.prefix, 'bin', 'python.exe')
target = os.path.join(sys.prefix, 'lib', 'site-packages')
# upgrade pip
subprocess.call([python_exe, '-m', 'ensurepip'])
subprocess.call([python_exe, '-m', 'pip', 'install', '--upgrade', 'pip'])
# install tensorflow package
subprocess.call([python_exe, '-m', 'pip', 'install', '--upgrade', 'tensorflow', '-t', target])
Open the Text Editor window in Blender, paste this code into it and execute it by pressing the “Run Script” button with an arrow.
After installation, we can check the availability of TensorFlow in Blender by executing the following code from the Python console or Text Editor:
import tensorflow as tf
# tf.Tensor(-261.76862, shape=(), dtype=float32)
If you have a graphic card with CUDA support, TensorFlow can compute using the GPU. To enable this mode, it needs to additionally install:
- NVIDIA GPU Drivers
- CUDA Toolkit 11.2 or later
- cuDNN SDK 8.1.0 or older
- (if necessary) TensorRT 6.0 or later
See the official TensorFlow website for GPU installation details.
After installing the listed applications, TensorFlow must automatically connect to the GPU itself.
Hi ! Thanks for this article ! On my side (Blender 2.81 on linux) the installation process goes well but “import tensoflow” returns “No module named ‘tensorflow’
Any idea ?
Try to set the “target” parameter manually – specify the path to blender python in it.
Hello, I got errors in the last phase (tensor package) in install.. I use Admin mode but write restriction.
Hello! Maybe your admin mode is not full. You need to be under the admin account and run blender as administrator.
Or you can try to download the portable version of Blender, install it somewhere but not in your “Program Files” directory, and try to install TensorFlow to this Blender installation.