uwsgi with flask tf.config.list_physical_devices('GPU') return empty

22 Views Asked by At
Python 3.8.10
cuda 11.8
cudnn 8.6.0
tensorflow 2.13.1
uWSGI 2.0.20

When I run it from Python3, the GPU shows fine.

log

python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
2024-02-27 08:39:18.729048: I tensorflow/core/util/port.cc:110] 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-02-27 08:39:18.775111: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-02-27 08:39:19.800299: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
2024-02-27 08:39:20.761868: I tensorflow/compiler/xla/stream_executor/cuda/cuda_gpu_executor.cc:995] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2024-02-27 08:39:20.794782: I tensorflow/compiler/xla/stream_executor/cuda/cuda_gpu_executor.cc:995] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2024-02-27 08:39:20.795010: I tensorflow/compiler/xla/stream_executor/cuda/cuda_gpu_executor.cc:995] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

but When I run my code through uwsgi it returns an empty array.

uwsgi python code

import tensorflow as tf
gpus = tf.config.list_physical_devices('GPU')
print(gpus)

uwsgi log

Python version: 3.8.10 (default, Nov 22 2023, 10:22:35)  [GCC 9.4.0]    
spawned uWSGI master process (pid: 5048)
spawned uWSGI worker 1 (pid: 5049, cores: 8)
2024-02-27 08:42:41.621085: I tensorflow/core/util/port.cc:110] 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-02-27 08:42:41.668013: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-02-27 08:42:42.837088: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
2024-02-27 08:42:43.874862: I tensorflow/compiler/xla/stream_executor/cuda/cuda_gpu_executor.cc:995] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2024-02-27 08:42:43.907051: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1960] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
[]

uwsgi.ini

[uwsgi]
base = /home/ubuntu/myapp
project = myapp
chdir = %(base)
module = wsgi:application

processes = 1
threads = 8
socket = /home/ubuntu/myapp.sock
chmod-socket = 666
vacuum = true
logto = %(base)/logs/uwsgi.log
pidfile2=/tmp/uwsgi.pid
lazy-apps = true
touch-chain-reload = /tmp/uwsgi.pid
socket-timeout = 10
listen = 1024

master = true

enable-threads = true

reload-mercy = 30

reload-on-rss = 1400

max-worker-lifetime = 3600

harakiri = 120
pythonpath = /home/ubuntu/.local/lib/python3.8/site-packages/

plugin = python3
0

There are 0 best solutions below