Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot find sundials when using google colab #150

Open
userrand opened this issue Jun 11, 2023 · 4 comments
Open

cannot find sundials when using google colab #150

userrand opened this issue Jun 11, 2023 · 4 comments

Comments

@userrand
Copy link

userrand commented Jun 11, 2023

Thank you for this package.

I am trying to install this package on google colab but none of the methods I tried so far worked.

I am having trouble getting nix installed on google colab as it seems to install but the nix commands that I tried do not work.

Using pip install, the package seems to have trouble finding sundials. This might be linked to https://scikits-odes.readthedocs.io/en/stable/installation.html?highlight=%24SUNDIALS_INST#linking-errors but I do not understand that paragraph. What does pass the correct one via the $SUNDIALS_INST environment variable. mean in code ?

@aragilar
Copy link
Collaborator

How did you install SUNDIALS? If you have not installed it, you'll need to install it first.

Once you've installed SUNDIALS, in a bash shell, run
export SUNDIALS_INST=<path_you_installed_sundials_at>, and then run pip.

@userrand
Copy link
Author

userrand commented Jun 11, 2023

How did you install SUNDIALS? If you have not installed it, you'll need to install it first.

Once you've installed SUNDIALS, in a bash shell, run export SUNDIALS_INST=<path_you_installed_sundials_at>, and then run pip.

Thank you for your very quick reply

I did the following in a google colab notebook (the ! are used to execute shell commands in one line, ----\ is a personal notation to indicate different jupyter cells (might be irrelevant), %%shell is used to consider the entire cell as a shell command

! wget https://github.com/LLNL/sundials/releases/download/v6.5.1/sundials-6.5.1.tar.gz

 \----\

! mkdir sundial

\----\

! tar -xzvf sundials-6.5.1.tar.gz -C sundials

\----\

%%shell

cd sundials
mkdir build-sundials-6.5.1
cd build-sundials-6.5.1
cmake -DLAPACK_ENABLE=ON -DSUNDIALS_INDEX_SIZE=64 ../sundials-6.5.1/
make 
make install

\-----\

%%shell

export SUNDIALS_INST=/usr/local

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

pip install scikits.odes

\----\

import pkg_resources
pkg_resources.get_distribution("scikits.odes").version


\----\

pip install nose

\-----\

import collections
collections.Callable = collections.abc.Callable
import scikits.odes as od; od.test()

@userrand
Copy link
Author

userrand commented Jun 11, 2023

@aragilar

just mentioning that the code above did not work as my answer did not mention that

@userrand
Copy link
Author

userrand commented Jun 11, 2023

I tried with nix

 ! bash <(curl -L https://nixos.org/nix/install) --daemon --yes

\----\

%%shell

source /etc/bashrc

nix-shell -p python37Packages.scikits-odes -p python37Packages.numpy --run "python3"

and got the following error

error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'shell'
         whose name attribute is located at /nix/store/l6fcz7knk5y1p8zz3fn9l7ifg8jvjhpc-nixpkgs/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:303:7

       … while evaluating attribute 'buildInputs' of derivation 'shell'

         at /nix/store/l6fcz7knk5y1p8zz3fn9l7ifg8jvjhpc-nixpkgs/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:350:7:

          349|       depsHostHost                = lib.elemAt (lib.elemAt dependencies 1) 0;
          350|       buildInputs                 = lib.elemAt (lib.elemAt dependencies 1) 1;
             |       ^
          351|       depsTargetTarget            = lib.elemAt (lib.elemAt dependencies 2) 0;

       error: undefined variable 'python37Packages'

       at «string»:1:107:

            1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (python37Packages.scikits-odes) (python37Packages.numpy) ]; } ""
             |                                                                                                           ^
---------------------------------------------------------------------------
CalledProcessError                        Traceback (most recent call last)
[<ipython-input-6-6d90f54bf14f>](https://localhost:8080/#) in <cell line: 1>()
----> 1 get_ipython().run_cell_magic('shell', '', '\nsource /etc/bashrc\n\nnix-shell -p python37Packages.scikits-odes -p python37Packages.numpy --run "python3"\n')

3 frames
[/usr/local/lib/python3.10/dist-packages/google/colab/_system_commands.py](https://localhost:8080/#) in check_returncode(self)
    135   def check_returncode(self):
    136     if self.returncode:
--> 137       raise subprocess.CalledProcessError(
    138           returncode=self.returncode, cmd=self.args, output=self.output
    139       )

CalledProcessError: Command '
source /etc/bashrc

nix-shell -p python37Packages.scikits-odes -p python37Packages.numpy --run "python3"
' returned non-zero exit status 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants