Skip to content

Commit

Permalink
chore: add bash scripts for conda
Browse files Browse the repository at this point in the history
  • Loading branch information
EdanToledo committed Aug 24, 2024
1 parent 38a61aa commit b3b7c2b
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
37 changes: 37 additions & 0 deletions bash_scripts/create_conda_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

# Check if the accelerator argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 <accelerator>"
echo "Available options for <accelerator>: tpu, gpu, cpu"
exit 1
fi

ACCELERATOR=$1

# Activate Conda
source ~/miniconda3/etc/profile.d/conda.sh

# Create a new Conda environment
conda create -n stx python=3.10 -y

# Activate the environment
conda activate stx

# Install packages with pip
pip install -e .

# Install JAX with the appropriate accelerator support
if [ "$ACCELERATOR" == "tpu" ]; then
pip install -U "jax[tpu]" -f https://storage.googleapis.com/jax-releases/libtpu_releases.html
elif [ "$ACCELERATOR" == "gpu" ]; then
pip install -U "jax[cuda]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
elif [ "$ACCELERATOR" == "cpu" ]; then
pip install -U jax
else
echo "Invalid accelerator type: $ACCELERATOR"
echo "Available options: tpu, gpu, cpu"
exit 1
fi

echo "Installation complete with $ACCELERATOR support."
40 changes: 40 additions & 0 deletions bash_scripts/install_conda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

# Exit immediately if a command exits with a non-zero status
set -e

# Step 1: Download Miniconda
CONDA_INSTALLER="Miniconda3-latest-Linux-x86_64.sh"
CONDA_URL="https://repo.anaconda.com/miniconda/$CONDA_INSTALLER"

echo "Downloading Miniconda installer..."
if ! wget -q --show-progress "$CONDA_URL"; then
echo "Error: Failed to download Miniconda installer."
exit 1
fi

# Step 2: Install Miniconda (silently with default settings)
echo "Installing Miniconda..."
bash "$CONDA_INSTALLER" -b

# Clean up the installer after installation
rm -f "$CONDA_INSTALLER"

# Step 3: Initialize Conda (Assuming bash shell)
CONDA_PATH="$HOME/miniconda3"

# Ensure Conda is initialized on every new shell
if ! grep -q "source $CONDA_PATH/etc/profile.d/conda.sh" ~/.bashrc; then
echo "source $CONDA_PATH/etc/profile.d/conda.sh" >> ~/.bashrc
echo "Conda initialization added to .bashrc"
fi

# Apply the .bashrc changes to the current shell session
echo "Initializing Conda for the current shell..."
source "$CONDA_PATH/etc/profile.d/conda.sh"

echo "Miniconda installation and initialization complete."

# Optional: Update conda to the latest version
echo "Updating Conda to the latest version..."
conda update -n base -c defaults conda -y
2 changes: 2 additions & 0 deletions bash_scripts/run-algorithms.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

# A simple script to run various algorithms - used for testing purposes

echo "Running All Algorithms..."

python stoix/systems/ppo/anakin/ff_ppo.py arch.total_timesteps=300 arch.total_num_envs=8 arch.num_evaluation=1 system.rollout_length=8
Expand Down

0 comments on commit b3b7c2b

Please sign in to comment.