TF installation, WSL2, and Visual Studio Code

I followed the instructions on tensorflow.org to install tensorflow on WSL2. It seems to work. This is by running the GPU verification code on the website. However, when I run the same code in Visual Studio Code. It couldn’t find the GPU. On VSC, I did pick the same kernel.

Let me show step by step. On WSL2, the verification code does show GPU:

(tf) dlin@SCL-DLIN:~$ python3 -c “import tensorflow as tf; print(tf.config.list_physical_devices(‘GPU’))”
2024-04-04 20:21:11.437247: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable TF_ENABLE_ONEDNN_OPTS=0.
2024-04-04 20:21:11.463715: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-04-04 20:21:11.843862: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
2024-04-04 20:21:12.267983: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:984] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-04-04 20:21:12.292401: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:984] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-04-04 20:21:12.292469: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:984] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
[PhysicalDevice(name=‘/physical_device:GPU:0’, device_type=‘GPU’)]

However, on VSC, it shows the following messages:

What do I do to make the verification code run on VSC? Thanks.

I later found that the Tensorflow GPU test scripts work in a .py file. But it does not work in Jupyter notebook. This is when use with VS Code. Somehow my VS Code configuration does not enable Jupyter notebooks to use GPU. Please help.

Setting up TensorFlow on Windows Subsystem for Linux 2 (WSL2) involves enabling WSL2, installing TensorFlow within WSL2, and integrating it with Visual Studio Code (VS Code) using the Remote - WSL extension for seamless development.
Visit Our Website: MC Height

I am able to run TensorFlow on WSL2 on VS Code if I run .py files. My issue is when I use Jupyter notebook under the same conda environment, it cannot find the GPU. The problem exists in both Windows native and WSL2.

What is the URL of MC Height?

As shown below, if I run TF .py code, it works fine.

However, if I put the same code in Jupyter notebook, it cannot find the GPU.

.

This problem exists in only one of my 4 computers. I set these 4 computers up the same way. The other 3 work perfectly. Just this new laptop is giving me problems and I have spent 3 days trying to debug. Just odd…