Skip to content
Snippets Groups Projects
Commit c9053859 authored by Daniel Müller's avatar Daniel Müller :speech_balloon:
Browse files

Add tensorflow installer

- Add task to check if tensorflow is installed alread
- Add script to download and install prebuilt wheel
parent 690f2d6a
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
gdownload() {
URL=$1
OUTFILE=$2
COOKIES="/tmp/${RANDOM}.cookie"
if [ -z "$URL" -o -z "$OUTFILE" ]; then
return 1
fi
# Get cookie with skip verification code
curl -sc "$COOKIES" "$URL" &> /dev/null
# Extract skip verification code from cookie
CODE="$(awk '/_warning_/ {print $NF}' $COOKIES)"
echo "Code: $CODE"
# Download the actual file
echo "Using link: " "$URL&confirm=$CODE"
curl -Lb "$COOKIES" "$URL&confirm=$CODE" -o "$OUTFILE"
# Cleanup cookie file
rm "$COOKIES"
return $?
}
install() {
DLFILE="/tmp/tensorflow-2.7.0-cp39-none-linux_aarch64.whl"
# Try to download the wheel file from google drive
if gdownload "https://drive.google.com/uc?export=download&id=1D3R7bzkuFdY_gGTkSmnF9IbRNlj9wssB" "$DLFILE"; then
# Install the downloaded wheel
pip3 install "$DLFILE"
# Save the pip3 install return code (0 => success)
PIPRC="$?"
# Cleanup the downloaded wheel
rm "$DLFILE"
return $PIPRC
fi
return 1
}
install
...@@ -20,3 +20,21 @@ ...@@ -20,3 +20,21 @@
virtualenv_command: /usr/bin/python3 -m venv virtualenv_command: /usr/bin/python3 -m venv
requirements: /tmp/ml-requirements.txt requirements: /tmp/ml-requirements.txt
virtualenv: "/home/{{ target_user }}/.ml-venv" virtualenv: "/home/{{ target_user }}/.ml-venv"
- name: Check if tensorflow is installed
shell: ". /home/{{ target_user }}/.ml-venv/bin/activate && pip3 freeze | grep -q tensorflow==2.7"
register: tfinstalled
changed_when: "tfinstalled.rc != 0"
failed_when: false
- name: Copy tf install script to remote fs
copy:
src: files/tensorflow-install.sh
dest: /tmp/tensorflow-install.sh
when: "tfinstalled.rc != 0"
- name: Download and install prebuilt tensorflow wheel
shell: ". /home/{{ target_user }}/.ml-venv/bin/activate && sh /tmp/tensorflow-install.sh"
when: "tfinstalled.rc != 0"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment