Hi - I’m trying to setup a nix-shell to serve as a development environment for python.
I’m relatively new to Nix but recently setup a NixOS laptop and am using home-manager.
I’m working on a deep reinforcement learning project and basically want to create a shell that provides python 3 with griddly
. I’d like to eventually install ray/RLlib
, pytorch
, and maybe a handful of hopefully easier-to-install packages, but I’m stuck just getting griddly
working right now.
Here’s my current nix-shell:
# Pinning is more reproducible but maybe conflicts with the libs installed by NixOS?
# { pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/9df2cb074d72ea80ac9fd225b29060c8cf13dd39.tar.gz") {} }:
{ pkgs ? import <nixpkgs> {} }:
let
mach-nix = import (
builtins.fetchGit {
url = "https://github.com/DavHau/mach-nix/";
ref = "refs/tags/3.3.0";
}
) {};
custom-python = mach-nix.mkPython {
python = "python38";
requirements = ''
pip
ipython
griddly
matplotlib
pygame
'';
providers = {
_default = "wheel,sdist,nixpkgs";
};
};
in
with pkgs;
mkShell {
buildInputs = [
# griddly requires the Vulkan-SDK. Is this it?
vulkan-headers
vulkan-loader
vulkan-tools
custom-python
];
# Do I need this?
# LD_LIBRARY_PATH="/run/opengl-driver/lib:/run/opengl-driver-32/lib";
}
Then, I have a simple test script in model.py
:
import gym
from gym.utils.play import play
env = gym.make('GDY-Sokoban-v0')
play(env, fps=10, zoom=2)
That gives me:
pygame 2.0.1 (SDL 2.0.14, Python 3.8.9)
Hello from the pygame community. https://www.pygame.org/contribute.html
/nix/store/kqx25j1w5cpvw5xflmr31y6qfczrk0my-python3-3.8.9-env/lib/python3.8/site-packages/gym/logger.py:30: UserWarning: WARN: failed to set matplotlib backend, plotting will not work: No module named '_tkinter'
warnings.warn(colorize('%s: %s'%('WARN', msg % args), 'yellow'))
Traceback (most recent call last):
File "model.py", line 3, in <module>
from griddly import GymWrapperFactory
File "/nix/store/kqx25j1w5cpvw5xflmr31y6qfczrk0my-python3-3.8.9-env/lib/python3.8/site-packages/griddly/__init__.py", line 16, in <module>
gd = importlib.import_module('python_griddly')
File "/nix/store/hq6mrm0pc6xn6j8y6lm4qcgg9rwmqd8q-python3-3.8.9/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: libvulkan.so.1: cannot open shared object file: No such file or directory
It looks like there are two problems here:
- finding
_tkinter
- finding
libvulkan.so.1
vkcube
, a simple vulkan test program included in vulkan-tools
, seems to work well in this shell and give me >1000 FPS.
I’m not really sure how to navigate either of these issues in NixOS, so I’d appreciate help debugging what’s going on here. Thank you!