Skip to content

Instantly share code, notes, and snippets.

@idontgetoutmuch
Created September 22, 2019 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idontgetoutmuch/07654bf741dce9a59d9f7fe74a2c45e3 to your computer and use it in GitHub Desktop.
Save idontgetoutmuch/07654bf741dce9a59d9f7fe74a2c45e3 to your computer and use it in GitHub Desktop.
[nix-shell:~]$ echo $LD_LIBRARY_PATH
/run/opengl-driver/lib
[nix-shell:~]$ python
Python 3.7.4 (default, Jul 8 2019, 18:31:06)
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
/nix/store/kfa0pylfvrzhpmm90kfr6q2pyr1lswxm-python3-3.7.4-env/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
/nix/store/kfa0pylfvrzhpmm90kfr6q2pyr1lswxm-python3-3.7.4-env/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/nix/store/kfa0pylfvrzhpmm90kfr6q2pyr1lswxm-python3-3.7.4-env/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
/nix/store/kfa0pylfvrzhpmm90kfr6q2pyr1lswxm-python3-3.7.4-env/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/nix/store/kfa0pylfvrzhpmm90kfr6q2pyr1lswxm-python3-3.7.4-env/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
/nix/store/kfa0pylfvrzhpmm90kfr6q2pyr1lswxm-python3-3.7.4-env/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
WARNING: Logging before flag parsing goes to stderr.
W0922 08:53:03.136390 139741779114880 __init__.py:308] Limited tf.compat.v2.summary API due to missing TensorBoard installation.
>>> tf.test.is_gpu_available()
2019-09-22 08:53:07.488484: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2019-09-22 08:53:07.505824: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2596990000 Hz
2019-09-22 08:53:07.506238: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x178d2f0 executing computations on platform Host. Devices:
2019-09-22 08:53:07.506266: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): <undefined>, <undefined>
2019-09-22 08:53:07.507573: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Could not dlopen library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory
2019-09-22 08:53:07.507593: E tensorflow/stream_executor/cuda/cuda_driver.cc:318] failed call to cuInit: UNKNOWN ERROR (303)
2019-09-22 08:53:07.507618: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: CUDA
2019-09-22 08:53:07.507628: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: CUDA
2019-09-22 08:53:07.507685: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:200] libcuda reported version is: Not found: was unable to find libcuda.so DSO loaded into this program
2019-09-22 08:53:07.507719: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:204] kernel reported version is: 435.21.0
False
@idontgetoutmuch
Copy link
Author

with import <nixpkgs> { config.allowUnfree = true; };

LD_LIBRARY_PATH=${linuxPackages.nvidia_x11}/lib $out/bin/auto.out "\$@"

stdenv.mkDerivation { name = "myCUDA"; buildInputs = [ (python37.withPackages (pkgs: [pkgs.tensorflowWithCuda])) ]; }

@idontgetoutmuch
Copy link
Author

with import <nixpkgs> { config.allowUnfree = true; };

stdenv.mkDerivation {
 name = "myCUDA";
 buildInputs = [ (python37.withPackages (pkgs: [pkgs.tensorflowWithCuda])) ];
 shellHook = ''
             LD_LIBRARY_PATH=${linuxPackages.nvidia_x11}/lib $out/bin/auto.out "\$@"
             '';
}

gives

[sundials@CUDA:~/cuda]$ nix-shell
bash: /nix/store/cmsv5qz437dispgqc0plr7jkcypvbxvh-myCUDA/bin/auto.out: No such file or directory

@idontgetoutmuch
Copy link
Author

[nix-shell:~/cuda]$ python
Python 3.7.4 (default, Jul  8 2019, 18:31:06) 
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf 
/nix/store/kfa0pylfvrzhpmm90kfr6q2pyr1lswxm-python3-3.7.4-env/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/nix/store/kfa0pylfvrzhpmm90kfr6q2pyr1lswxm-python3-3.7.4-env/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/nix/store/kfa0pylfvrzhpmm90kfr6q2pyr1lswxm-python3-3.7.4-env/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/nix/store/kfa0pylfvrzhpmm90kfr6q2pyr1lswxm-python3-3.7.4-env/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/nix/store/kfa0pylfvrzhpmm90kfr6q2pyr1lswxm-python3-3.7.4-env/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/nix/store/kfa0pylfvrzhpmm90kfr6q2pyr1lswxm-python3-3.7.4-env/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
WARNING: Logging before flag parsing goes to stderr.
W0922 09:16:06.724925 140376916327424 __init__.py:308] Limited tf.compat.v2.summary API due to missing TensorBoard installation.
>>> tf.test.is_gpu_available()
2019-09-22 09:16:09.266998: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2019-09-22 09:16:09.284007: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2596990000 Hz
2019-09-22 09:16:09.284429: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x23baf00 executing computations on platform Host. Devices:
2019-09-22 09:16:09.284453: I tensorflow/compiler/xla/service/service.cc:175]   StreamExecutor device (0): <undefined>, <undefined>
2019-09-22 09:16:09.720464: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcuda.so.1
2019-09-22 09:16:09.903170: E tensorflow/stream_executor/cuda/cuda_driver.cc:318] failed call to cuInit: CUDA_ERROR_UNKNOWN: unknown error
2019-09-22 09:16:09.903211: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: CUDA
2019-09-22 09:16:09.903223: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: CUDA
2019-09-22 09:16:09.903305: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:200] libcuda reported version is: 435.21.0
2019-09-22 09:16:09.903334: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:204] kernel reported version is: 435.21.0
2019-09-22 09:16:09.903344: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:310] kernel version seems to match DSO: 435.21.0
False

@idontgetoutmuch
Copy link
Author

[nix-shell:~/cuda]$ nvidia-smi
Sun Sep 22 09:26:53 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 435.21       Driver Version: 435.21       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla K80           Off  | 00003130:00:00.0 Off |                    0 |
| N/A   35C    P0    54W / 149W |      0MiB / 11441MiB |      9%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment