-
-
Notifications
You must be signed in to change notification settings - Fork 656
Description
With the release of rules_python 1.8.1, I assume the venv support is ready for general use, so I decide to give it a try, with latest bazel 8.
common --@rules_python//python/config_settings:bootstrap_impl=script
common --@rules_python//python/config_settings:venvs_site_packages=yes
common --@rules_python//python/config_settings:venvs_use_declare_symlink=yes
I wrote a dummy py_binary utils/tf_test.py
import tensorflow as tf
print(f"TensorFlow version: {tf.__version__}")
gpus = tf.config.list_physical_devices("GPU")
print(f"TF devices (GPU): {gpus}")
requirements.in:
tensorflow[and-cuda]==2.19.1
utils/BUILD:
load("@rules_python//python:defs.bzl", "py_binary")
load("@third_party_lib//:requirements.bzl", "requirement")
py_binary(
name = "tf_test",
srcs = ["tf_test.py"],
deps = [
requirement("tensorflow"),
],
)
bazel run //utils:tf_test complains
2026-01-21 19:46:05.488619: I external/local_xla/xla/tsl/cuda/cudart_stub.cc:32] Could not find cuda drivers on your machine, GPU will not be used.
2026-01-21 19:46:05.514317: I external/local_xla/xla/tsl/cuda/cudart_stub.cc:32] Could not find cuda drivers on your machine, GPU will not be used.
We do have libcudart.so.12 in bazel-bin/utils/tf_test.runfiles/_main/utils/_tf_test.venv/lib/python3.10/site-packages/nvidia/cuda_runtime/lib/libcudart.so.12
While troubleshooting, I noticed in the bazel-bin/utils/tf_test.runfiles/_main/utils/_tf_test.venv/lib/python3.10/site-packages/tensorflow/ directory, all the py files have relative symlinks, but the so files have absolute symlinks to my user bazel cache dir. Is that expected? Why didn't we also use relative symlink for so files?
gfrankliu-ws ➜ pwd
/home/gfrankliu/test/bazel-bin/utils/tf_test.runfiles/_main/utils/_tf_test.venv/lib/python3.10/site-packages/tensorflow
gfrankliu-ws ➜ ls -l
total 68
lrwxrwxrwx 1 gfrankliu gfrankliu 118 Jan 21 18:34 THIRD_PARTY_NOTICES.txt -> ../../../../../../../rules_python++pip+third_party_lib_310_tensorflow/site-packages/tensorflow/THIRD_PARTY_NOTICES.txt
lrwxrwxrwx 1 gfrankliu gfrankliu 106 Jan 21 18:34 __init__.py -> ../../../../../../../rules_python++pip+third_party_lib_310_tensorflow/site-packages/tensorflow/__init__.py
drwxr-xr-x 2 gfrankliu gfrankliu 4096 Jan 21 18:34 __pycache__
lrwxrwxrwx 1 gfrankliu gfrankliu 99 Jan 21 18:34 _api -> ../../../../../../../rules_python++pip+third_party_lib_310_tensorflow/site-packages/tensorflow/_api
lrwxrwxrwx 1 gfrankliu gfrankliu 103 Jan 21 18:34 compiler -> ../../../../../../../rules_python++pip+third_party_lib_310_tensorflow/site-packages/tensorflow/compiler
drwxr-xr-x 4 gfrankliu gfrankliu 4096 Jan 21 18:34 core
lrwxrwxrwx 1 gfrankliu gfrankliu 105 Jan 21 18:34 distribute -> ../../../../../../../rules_python++pip+third_party_lib_310_tensorflow/site-packages/tensorflow/distribute
lrwxrwxrwx 1 gfrankliu gfrankliu 102 Jan 21 18:34 dtensor -> ../../../../../../../rules_python++pip+third_party_lib_310_tensorflow/site-packages/tensorflow/dtensor
lrwxrwxrwx 1 gfrankliu gfrankliu 102 Jan 21 18:34 include -> ../../../../../../../rules_python++pip+third_party_lib_310_tensorflow/site-packages/tensorflow/include
lrwxrwxrwx 1 gfrankliu gfrankliu 183 Jan 21 18:34 libtensorflow_cc.so.2 -> /home/gfrankliu/.cache/bazel/_bazel_gfrankliu/0c06fba63a99dbe47301a331635af967/external/rules_python++pip+third_party_lib_310_tensorflow/site-packages/tensorflow/libtensorflow_cc.so.2
lrwxrwxrwx 1 gfrankliu gfrankliu 190 Jan 21 18:34 libtensorflow_framework.so.2 -> /home/gfrankliu/.cache/bazel/_bazel_gfrankliu/0c06fba63a99dbe47301a331635af967/external/rules_python++pip+third_party_lib_310_tensorflow/site-packages/tensorflow/libtensorflow_framework.so.2
lrwxrwxrwx 1 gfrankliu gfrankliu 99 Jan 21 18:34 lite -> ../../../../../../../rules_python++pip+third_party_lib_310_tensorflow/site-packages/tensorflow/lite
drwxr-xr-x 4 gfrankliu gfrankliu 4096 Jan 21 18:34 python
lrwxrwxrwx 1 gfrankliu gfrankliu 103 Jan 21 18:34 security -> ../../../../../../../rules_python++pip+third_party_lib_310_tensorflow/site-packages/tensorflow/security
lrwxrwxrwx 1 gfrankliu gfrankliu 100 Jan 21 18:34 tools -> ../../../../../../../rules_python++pip+third_party_lib_310_tensorflow/site-packages/tensorflow/tools
lrwxrwxrwx 1 gfrankliu gfrankliu 98 Jan 21 18:34 tsl -> ../../../../../../../rules_python++pip+third_party_lib_310_tensorflow/site-packages/tensorflow/tsl
lrwxrwxrwx 1 gfrankliu gfrankliu 114 Jan 21 18:34 xla_aot_runtime_src -> ../../../../../../../rules_python++pip+third_party_lib_310_tensorflow/site-packages/tensorflow/xla_aot_runtime_src
gfrankliu-ws ➜
I also tried LD_DEBUG=libs bazel run //utils:tf_test and see it search the python packages, but using the absolute path, thus failed. See attached find_libcudart.txt