Skip to content

Commit

Permalink
Add GCP option with DLVM commands (tensorflow#548)
Browse files Browse the repository at this point in the history
* Add DLVM commands
  • Loading branch information
texasmichelle authored Oct 22, 2020
1 parent 824f9fb commit 4db2e67
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 2 deletions.
89 changes: 89 additions & 0 deletions Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
To install Swift for TensorFlow, download one of the packages below and follow the instructions for your operating system. After installation, you can use the full suite of Swift tools, including `swift` (Swift REPL/interpreter) and `swiftc` (Swift compiler). See [here](Usage.md) for more details about using Swift for TensorFlow.

**Note:**
- As a shortcut, see the [GCP section](#google-cloud-platform) for instructions
on using a [Deep Learning VM image][dlvm] to spin up a pre-configured
environment.
- If you want to modify the Swift for TensorFlow source code or build with a custom version of TensorFlow, see [here](https://github.com/apple/swift/blob/tensorflow/README.md) for instructions on building from source.
- Swift for TensorFlow is an early stage project. It has been released to enable open source development and is not yet ready for general use by machine learning developers.

Expand Down Expand Up @@ -294,6 +297,89 @@ copy "%SDKROOT%\usr\share\winsdk.modulemap" "%UniversalCRTSdkDir%\Include\%UCRTV
<sup><a name="windows-python">6</a></sup> Provides `python` needed for Python integration. You may download it from [python](https://www.python.org/) instead.<br/>
<sup><a name="windows-sdk-deploy">7</a></sup> This will need to be re-run every time Visual Studio is updated. <br/>

# Google Cloud Platform

***Experimental***

To save on setup time, you can leverage one of the Swift for Tensorflow
[Deep Learning VM][dlvm] images to quickly spin up a pre-configured Ubuntu
instance with an installed toolchain. To view the available images (currently
experimental):

```
gcloud compute images list \
--project deeplearning-platform-release \
--no-standard-images | \
grep swift
```

## CPU Instance

To create a small CPU instance:

```
gcloud compute instances create s4tf-ubuntu \
--image-project=deeplearning-platform-release \
--image-family=swift-latest-cpu-ubuntu-1804 \
--maintenance-policy=TERMINATE \
--machine-type=n1-standard-2 \
--boot-disk-size=256GB
```

This will create a single `n1-standard-2` instance with the Swift
toolchain installed. Once the instance is up, connect to it:

```
gcloud compute ssh s4tf-ubuntu \
--zone ${ZONE}
```

## GPU Instance

To create a GPU instance, the first step is to identify a zone that contains
the type of GPU you'd like to use, since not all zones have availability:

```
export GPU_TYPE="v100"
gcloud compute accelerator-types list | grep ${GPU_TYPE}
```

Using these results, set your zone:

```
export ZONE="us-west1-b"
```

To create an instance with an attached V100 GPU:

```
gcloud compute instances create s4tf-ubuntu-${GPU_TYPE} \
--zone=${ZONE} \
--image-project=deeplearning-platform-release \
--image-family=swift-latest-gpu-ubuntu-1804 \
--maintenance-policy=TERMINATE \
--accelerator="type=nvidia-tesla-${GPU_TYPE},count=1" \
--metadata="install-nvidia-driver=True" \
--machine-type=n1-highmem-2 \
--boot-disk-size=256GB
```

This will create a single `n1-highmem-2` instance with an attached accelerator
and the Swift toolchain installed with all CUDA libraries.

***Note:*** *If this command fails due to lack of quota, you will need to find
a zone with available quota or request an increase. Using the search feature in
the [Quotas section of the GCP Console][gcp_quotas], you can view your current
usage and submit an increase request (e.g. search for "V100" or the value you
used in `$GPU_TYPE`).*

Once the instance is up, connect to it:

```
gcloud compute ssh s4tf-ubuntu-${GPU_TYPE} \
--zone ${ZONE}
```

# Verify the Installation

Create a text file `test.swift` with the following contents:
Expand Down Expand Up @@ -328,3 +414,6 @@ If you see this output, you have successfully installed Swift for TensorFlow!
[[2.0, 4.0],
[6.0, 8.0]]
```

[dlvm]: https://cloud.google.com/ai-platform/deep-learning-vm/docs
[gcp_quotas]: https://console.cloud.google.com/iam-admin/quotas
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,18 @@ The Swift for TensorFlow project is currently focusing on 2 kinds of users:
or start from a [blank notebook][blank_notebook]!
Read more in our [usage guide](Usage.md).

- **Install locally**: you can [download a pre-built Swift for TensorFlow
- **Install locally**: You can [download a pre-built Swift for TensorFlow
package](Installation.md). After installation, you can follow these
[step-by-step instructions](Usage.md) to build and execute a Swift script on
your computer.

- **Run on GCP**: You can spin up a GCE instance using a Swift for TensorFlow
[Deep Learning VM][dlvm] image, with all drivers and the toolchain
pre-installed. Instructions can be found in the
[Installation Guide](Installation.md).

- **Compile from source**: If you'd like to customize Swift for TensorFlow or
contribute back, follow our [instructions](https://github.com/apple/swift/tree/tensorflow#building-swift-for-tensorflow)
contribute back, follow our [instructions][instructions]
on building Swift for TensorFlow from source.

### Tutorials ![](https://www.tensorflow.org/images/colab_logo_32px.png)
Expand Down Expand Up @@ -238,3 +243,5 @@ Conduct](CODE_OF_CONDUCT.md), which we encourage everybody to read before
participating.

[blank_notebook]: https://colab.research.google.com/notebook#create=true&language=swift
[dlvm]: https://cloud.google.com/ai-platform/deep-learning-vm/docs
[instructions]: https://github.com/apple/swift/tree/tensorflow#building-swift-for-tensorflow

0 comments on commit 4db2e67

Please sign in to comment.