Skip to content

Commit 880a5b9

Browse files
marcrasidan-zheng
authored andcommittedOct 4, 2019
add script that installs s4tf and deps on ubuntu1804 (tensorflow#233)
1 parent afdef94 commit 880a5b9

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed
 

‎utils/install-ubuntu1804.sh

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/bash
2+
3+
# Installs a Swift for TensorFlow toolchain from scratch on Ubuntu 18.04.
4+
#
5+
# Usage:
6+
# ./install-ubuntu1804
7+
# [--toolchain-url TOOLCHAIN_URL]
8+
# [--jupyter-url JUPYTER_URL]
9+
# [--cuda CUDA_VERSION]
10+
# [--no-jupyter]
11+
# [--install-location INSTALL_LOCATION]
12+
#
13+
# Arguments:
14+
# --toolchain-url: Specifies the URL for the toolchain. Defaults to the latest
15+
# nightly CPU-only toolchain.
16+
# --jupyter-url: Specifies the URL for swift-jupyter. Defaults to the latest
17+
# nightly build. Set this to the empty string to disable
18+
# swift-jupyter installation.
19+
# --install-location: Directory to extract the toolchain. Defaults to
20+
# "./swift-toolchain".
21+
22+
set -exuo pipefail
23+
24+
TOOLCHAIN_URL=https://storage.googleapis.com/swift-tensorflow-artifacts/nightlies/latest/swift-tensorflow-DEVELOPMENT-ubuntu18.04.tar.gz
25+
JUPYTER_URL=https://storage.googleapis.com/swift-tensorflow-artifacts/nightlies/latest/swift-jupyter.tar.gz
26+
INSTALL_LOCATION=./swift-toolchain
27+
28+
# Parse arguments.
29+
PARSE_ERROR="invalid arguments"
30+
while
31+
arg="${1-}"
32+
case "$arg" in
33+
--toolchain-url) TOOLCHAIN_URL="${2?"$PARSE_ERROR"}"; shift;;
34+
--jupyter-url) JUPYTER_URL="${2?"$PARSE_ERROR"}"; shift;;
35+
--install-location) INSTALL_LOCATION="${2?"$PARSE_ERROR"}"; shift;;
36+
"") break;;
37+
*) echo "$PARSE_ERROR" >&2; exit 2;;
38+
esac
39+
do
40+
shift
41+
done
42+
43+
# Install dependencies
44+
DEBIAN_FRONTEND=noninteractive
45+
sudo apt-get update
46+
sudo apt-get install -y --no-install-recommends \
47+
build-essential \
48+
ca-certificates \
49+
curl \
50+
git \
51+
python \
52+
python-dev \
53+
python-pip \
54+
python-setuptools \
55+
python-tk \
56+
python3 \
57+
python3-pip \
58+
python3-setuptools \
59+
clang \
60+
libcurl4-openssl-dev \
61+
libicu-dev \
62+
libpython-dev \
63+
libpython3-dev \
64+
libncurses5-dev \
65+
libxml2 \
66+
libblocksruntime-dev
67+
68+
# Download and extract Swift toolchain.
69+
mkdir -p "$INSTALL_LOCATION"
70+
wget "$TOOLCHAIN_URL" -O "$INSTALL_LOCATION"/swift-toolchain.tar.gz
71+
tar -xf "$INSTALL_LOCATION"/swift-toolchain.tar.gz -C "$INSTALL_LOCATION"
72+
rm "$INSTALL_LOCATION"/swift-toolchain.tar.gz
73+
74+
# Download, extract, and register Jupyter, if requested.
75+
if [[ ! -z "$JUPYTER_URL" ]]; then
76+
wget "$JUPYTER_URL" -O "$INSTALL_LOCATION"/swift-jupyter.tar.gz
77+
tar -xf "$INSTALL_LOCATION"/swift-jupyter.tar.gz -C "$INSTALL_LOCATION"
78+
rm "$INSTALL_LOCATION"/swift-jupyter.tar.gz
79+
80+
sudo pip3 install -r "$INSTALL_LOCATION"/swift-jupyter/requirements.txt
81+
82+
python3 "$INSTALL_LOCATION"/swift-jupyter/register.py --user --swift-toolchain "$INSTALL_LOCATION" --swift-python-library /usr/lib/x86_64-linux-gnu/libpython3.6m.so
83+
fi

0 commit comments

Comments
 (0)
Please sign in to comment.