Skip to content

Commit

Permalink
Default toolchain directory if not set
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksKnezevic committed Jan 7, 2025
1 parent 16c3a26 commit 654ab6e
Showing 1 changed file with 39 additions and 38 deletions.
77 changes: 39 additions & 38 deletions env/activate
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,47 @@
#

if [ -z "$TTMLIR_TOOLCHAIN_DIR" ]; then
echo "TTMLIR_TOOLCHAIN_DIR not set. Please set it and re-run"
ORANGE='\033[0;33m'
NC='\033[0m'
printf "${ORANGE}WARNING: TTMLIR_TOOLCHAIN_DIR not set. Defaulting to /opt/ttmlir-toolchain/ ${NC}\n"
export TTMLIR_TOOLCHAIN_DIR="/opt/ttmlir-toolchain/"
fi
if command -v sudo > /dev/null 2>&1; then
sudo apt-get install -y python3.11-dev python3.11-venv
else
if command -v sudo > /dev/null 2>&1; then
sudo apt-get install -y python3.11-dev python3.11-venv
else
apt-get install -y python3.11-dev python3.11-venv
fi

export TT_TORCH_HOME="$(pwd)"
export LD_LIBRARY_PATH=$TT_TORCH_HOME/env/venv/lib/python3.11/site-packages/torch/lib:$TTMLIR_TOOLCHAIN_DIR/lib:$TT_TORCH_HOME/install/lib/:$LD_LIBRRARY_PATH
apt-get install -y python3.11-dev python3.11-venv
fi

export TTMLIR_VENV_DIR="$(pwd)/env/venv"
if [ -d $TTMLIR_VENV_DIR/bin ]; then
[ -f $TTMLIR_VENV_DIR/bin/activate ] && source $TTMLIR_VENV_DIR/bin/activate
else
echo "Creating virtual environment in $TTMLIR_VENV_DIR"
python3.11 -m venv $TTMLIR_VENV_DIR
source $TTMLIR_VENV_DIR/bin/activate
pip install --upgrade pip
export TT_TORCH_HOME="$(pwd)"
export LD_LIBRARY_PATH=$TT_TORCH_HOME/env/venv/lib/python3.11/site-packages/torch/lib:$TTMLIR_TOOLCHAIN_DIR/lib:$TT_TORCH_HOME/install/lib/:$LD_LIBRRARY_PATH

python3.11 -m pip install -r requirements.txt
cd $TT_TORCH_HOME/third_party
git clone https://github.com/pytorch/vision.git
cd vision
git checkout v0.20.0
pip uninstall -y torchvision
TORCHVISION_USE_VIDEO_CODEC=0 TORCHVISION_USE_FFMPEG=0 CC=clang CXX=clang++ _GLIBCXX_USE_CXX11_ABI=1 USE_CUDA=OFF python setup.py install
cd $TT_TORCH_HOME
fi
export TTTORCH_ENV_ACTIVATED=1
export TTMLIR_ENV_ACTIVATED=1
export PATH=$TT_TORCH_HOME/third_party/tt-mlir/src/tt-mlir-build/bin:$TTMLIR_TOOLCHAIN_DIR/bin:$PATH
export TOKENIZERS_PARALLELISM=false
if [ -n "$PROJECT_ROOT" ]; then
export TT_METAL_HOME="$PROJECT_ROOT/third_party/tt-mlir/src/tt-mlir/third_party/tt-metal/src/tt-metal"
else
export TT_METAL_HOME="$(pwd)/third_party/tt-mlir/src/tt-mlir/third_party/tt-metal/src/tt-metal"
fi
export PYTHONPATH="$(pwd):$(pwd)/install/lib:$(pwd)/.local/toolchain/python_packages/mlir_core:${TT_METAL_HOME}:${TT_METAL_HOME}/tt_eager:${TT_METAL_BUILD_HOME}/tools/profiler/bin"
export ARCH_NAME="${ARCH_NAME:-wormhole_b0}"
export TT_METAL_LOGGER_LEVEL="ERROR"
export TTMLIR_VENV_DIR="$(pwd)/env/venv"
if [ -d $TTMLIR_VENV_DIR/bin ]; then
[ -f $TTMLIR_VENV_DIR/bin/activate ] && source $TTMLIR_VENV_DIR/bin/activate
else
echo "Creating virtual environment in $TTMLIR_VENV_DIR"
python3.11 -m venv $TTMLIR_VENV_DIR
source $TTMLIR_VENV_DIR/bin/activate
pip install --upgrade pip

python3.11 -m pip install -r requirements.txt
cd $TT_TORCH_HOME/third_party
git clone https://github.com/pytorch/vision.git
cd vision
git checkout v0.20.0
pip uninstall -y torchvision
TORCHVISION_USE_VIDEO_CODEC=0 TORCHVISION_USE_FFMPEG=0 CC=clang CXX=clang++ _GLIBCXX_USE_CXX11_ABI=1 USE_CUDA=OFF python setup.py install
cd $TT_TORCH_HOME
fi
export TTTORCH_ENV_ACTIVATED=1
export TTMLIR_ENV_ACTIVATED=1
export PATH=$TT_TORCH_HOME/third_party/tt-mlir/src/tt-mlir-build/bin:$TTMLIR_TOOLCHAIN_DIR/bin:$PATH
export TOKENIZERS_PARALLELISM=false
if [ -n "$PROJECT_ROOT" ]; then
export TT_METAL_HOME="$PROJECT_ROOT/third_party/tt-mlir/src/tt-mlir/third_party/tt-metal/src/tt-metal"
else
export TT_METAL_HOME="$(pwd)/third_party/tt-mlir/src/tt-mlir/third_party/tt-metal/src/tt-metal"
fi
export PYTHONPATH="$(pwd):$(pwd)/install/lib:$(pwd)/.local/toolchain/python_packages/mlir_core:${TT_METAL_HOME}:${TT_METAL_HOME}/tt_eager:${TT_METAL_BUILD_HOME}/tools/profiler/bin"
export ARCH_NAME="${ARCH_NAME:-wormhole_b0}"
export TT_METAL_LOGGER_LEVEL="ERROR"

0 comments on commit 654ab6e

Please sign in to comment.