сряда, 28 февруари 2024 г.

From 0 to working scientific python with pypolychord

This is a brand new Lenovo laptop I got as a backup because my dear Asus got broken. So I got this smaller and weaker but still cute laptop. So I wanted to make this post just to list the quickest install from 0 to a working python file. 

Install python and jupyter

1. pacman -S python3

2. pacman -S jupyter-notebook

Install miniconda3 (instructions here)

3. mkdir -p ~/miniconda3

4. cd ~/miniconda3                                                                                                                                                                                                        
5. wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh

6. bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3

7. ~/miniconda3/bin/conda init bash
 

Then install the packages I need. I'm pretty sure I have an exported file from this environment with the packages but this is the absolute minimum of stuff. 

8.
conda create --name myenv
conda install -n myenv pip
conda install ipykernel
python3 -m ipykernel install --user --name=myenv
pacman -S gcc
pip install wheel
sudo pacman -S make
sudo pacman -S gcc-fortran

(optional conda install libgcc - no idea if this helped)

sudo pacman -S gcc-libs

pip install numpy
pip install git+https://github.com/PolyChord/PolyChordLite@master
conda install matplotlib
pip install getdist

I was getting a persistent error with libstdc++.so.6 (see here for other suggestions), here's what I did (after I installed gcc-libs and gcc-fortran)

sudo find / -name "libstdc++.so*"
conda install -c anaconda libstdcxx-ng
conda update libstdcxx-ng
ls ~/miniconda3/envs/myenv/bin/../lib
cp /usr/lib/libstdc++.so.6.0.32 ~/miniconda3/envs/myenv/bin/../lib 

And then manually removing libstdc++.so.6.0.21 and libstdc++.so.6.0.29

The problem with mpi4py:

I was getting a kernel crash from inside polychord, that I know it's related to mpi4py. So I had to install it. When trying to pip install it, I woul get this error:

"The Open MPI wrapper compiler was unable to find the specified compiler
     x86_64-conda_cos6-linux-gnu-cc in your PATH.
      
     Note that this compiler was either specified at configure time or in
     one of several possible environment variables.
     --------------------------------------------------------------------------
     failure.
     removing: _configtest.c _configtest.o
     error: Cannot compile MPI programs. Check your configuration!!!"

Solving it took a long time and 3 gpts!
 >sudo pacman -S openmpi

>yay -S mpicc
 >yay -S mpich

>echo $PATH
>conda list #look for openmpi - I had it, but obviously not working well enough

x86_64-conda_cos6-linux-gnu-cc

which gcc
/usr/bin/gcc

which mpicc
~/miniconda3/envs/BAO/bin/mpicc
export MPICC=~/miniconda3/envs/BAO/bin/mpicc

>pip install mpi4py #longer output but still and error

The Open MPI wrapper compiler was unable to find the specified compiler
      x86_64-conda_cos6-linux-gnu-cc in your PATH.
      
      Note that this compiler was either specified at configure time or in
      one of several possible environment variables.
      --------------------------------------------------------------------------
      failure.
      removing: _configtest.c _configtest.o
      error: Cannot compile MPI programs. Check your configuration!!!

>which x86_64-conda_cos6-linux-gnu-cc
/i didn't have it anywhere/
>conda install x86_64-conda_cos6-linux-gnu-cc
ls ~/miniconda3/envs/BAO/bin #look for x86_64-conda_cos6-linux-gnu-cc - I have x86_64-conda-linux-gnu-cc
>export PATH=~/miniconda3/envs/BAO/bin:$PATH
>pip install mpi4py #nope, same error as above
>conda install -c conda-forge openmpi
>conda install -c conda-forge openmpi --force-reinstall
>pip install mpi4py #yay!!! 

It finally worked. As you can imagine, a lot of steps, it took a while to figure it out. But now polychord is working and all is fine. 


Edit (03.08.2024):

Assuming the system is already up and running with gcc, g++, mpi, mpich, openmpi, I just reinstalled the environment super quick with python 3.12

conda create --name BAOn  

conda activate BAOn

conda install pip

conda install ipykernel

python3 -m ipykernel install --user --name=BAOn

which pip #to confirm you're working within the environment 

pip install wheel  

pip install pillow 

pip install numpy==1.26 --force #to confirm it's not using the outside numpy   

conda install matplotlib

pip install openmpi  #note here on my computer conda install openmpi makes the calculation speed 3 times slower, so either do pip install openmpi or conda install mpich

which mpicc #to confirm the mpicc refers to the env  

pip install mpi4py --force #use force in case you have an old library
 

# see https://stackoverflow.com/questions/61003570/cannot-install-mpi4py-using-conda-and-specify-pre-installed-mpicc-path  

pip install git+https://github.com/PolyChord/PolyChordLite@master #this didn't work for me

#this below did work:

git clone https://github.com/PolyChord/PolyChordLite.git
cd PolyChordLite
make
pip install .

conda install jupyter
pip install emcee --force
pip install getdist
pip install anesthetic
 

Also, to useful commands (which I still haven't tried but I will in the future):

conda env export > BAOn.yml

conda env create -f BAOn.yml

 

понеделник, 19 февруари 2024 г.

Install Maple on a new Manjaro computer

 1. Install ld-lsb (the name of Linux Standard Base package in Manjaro)

2. Download Maple Network Tools from here

3. chmod +X NetworkToolsLinuxX64Installer.run and then run it to install the Network Tools

3. Install Maple and Activate. 

Without the Network Tools, Maple won't activate and will give you FLEXnet error with the license. Apart from that, everything installed flawlessly. No machine name complaints.