In order to program in python for deep learning projects utilizing CUDA, I configured a FHS environment using nix develop shell. Below is the flake.nix I use:
{
outputs = { nixpkgs, … }:
let
system="x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
in{
devShells.${system}.default = (pkgs.buildFHSEnv {
name = "myFHSEnv";
targetPkgs = pkgs: (with pkgs; [
...
micromamba # or mamba-cpp, they seem the same
]);
}).env;
};
}
This develop shell used to work fine, I can create mamba virtual environments and use nvcc like in regular linux distros.
Normally I would initiate the shell hook via eval"$(micromamba shell hook)", then micromamba activate $MYENV. However, after updating recently from micromamba v2.4.0 to v2.6.2, the command fails with
Error unknown MAMBA_EXE: "/nix/store/sasji2lzayyx46lndg549yavw9lpiwk3-mamba-cpp-2.6.2/bin/.mamba-wrapped", filename must be mamba or micromamba
Inspecting the scirpt, it uses a mysterious .mamba-wrapped instead of mamba as its binary:
$ mamba shell hook --shell zsh | head -n 10
# Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
__mamba_exe() (
"/nix/store/sasji2lzayyx46lndg549yavw9lpiwk3-mamba-cpp-2.6.2/bin/.mamba-wrapped" "${@}"
)
$ ls -l /nix/store/sasji2lzayyx46lndg549yavw9lpiwk3-mamba-cpp-2.6.2/bin/
.r-xr-xr-x 344 4.1k nobody 1 JAN 1970 mamba
For comparison, with micromamba v2.4.0:
$ micromamba shell hook --shell zsh | head -n 10
# Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
__mamba_exe() (
"/nix/store/vvbpam9c27gqzpik6lll1zfr4qiibm6g-micromamba-2.4.0/bin/micromamba" "${@}"
)
$ ls -l /nix/store/vvbpam9c27gqzpik6lll1zfr4qiibm6g-micromamba-2.4.0/bin/
-r-xr-xr-x 1 nobody nogroup 2483984 1 JAN 1970 micromamba
I tried manually edit __mamba_exe() in the script to replace .mamba-wrapped by mamba, it passed the binary name check, and I was able to micromamba create $MYENV. However, when I try to micromamba activate $MYENV:
$ mamba activate $MYENV
'.mamba-wrapped' is running as a subprocess and can't modify the parent shell.
Thus you must initialize your shell before using activate and deactivate.
To initialize the current zsh shell, run:
$ eval "$(.mamba-wrapped shell hook --shell zsh)"
and then activate or deactivate with:
$ .mamba-wrapped activate
To automatically initialize all future (zsh) shells, run:
$ .mamba-wrapped shell init --shell zsh --root-prefix=~/.local/share/mamba
If your shell was already initialized, reinitialize your shell with:
$ .mamba-wrapped shell reinit --shell zsh
Otherwise, this may be an issue. In the meantime you can run commands. See:
$ .mamba-wrapped run --help
Supported shells are {bash, zsh, csh, posix, xonsh, cmd.exe, powershell, fish, nu}.
critical libmamba Shell not initialized
Now, in my FHSEnv, mamba and .mamba-wrapper are all defined:
$ which mamba
/usr/bin/mamba
$ ll /usr/bin/mamba
lrwxrwxrwx - - nobody 1 JAN 1970 /usr/bin/mamba -> /nix/store/sasji2lzayyx46lndg549yavw9lpiwk3-mamba-cpp-2.6.2/bin/mamba
$ which .mamba-wrapped
/usr/bin/.mamba-wrapped
$ ll /usr/bin/.mamba-wrapped
lrwxrwxrwx - - nobody 1 JAN 1970 /usr/bin/.mamba-wrapped -> /nix/store/sasji2lzayyx46lndg549yavw9lpiwk3-mamba-cpp-2.6.2/bin/.mamba-wrapped
while only mamba exists in that directory:
$ ll /nix/store/sasji2lzayyx46lndg549yavw9lpiwk3-mamba-cpp-2.6.2/bin/
.r-xr-xr-x 344 4.1k nobody 1 JAN 1970 mamba
I am confused. Does anyone know the proper way to use mamba/micromamba in nix develop shell and FHSEnv?