Skip to content

johndpope/SwiftTorch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwiftPyTorch

Install Swift for Tensorflow

To install Swift for Tensorflow visit https://github.com/tensorflow/swift/.

Creating a new Xcode Projects?
See NewProjects.md.

Install OpenAI Gym

Take the following steps to install OpenAI Gym using Miniconda: Screenshot

Install these for gymai

brew install cmake boost boost-python sdl2 swig wget

(if sdl2 fails / try proceeding without it)

https://conda.io/docs/_downloads/conda-cheatsheet.pdf

Setting up miniconda

brew install wget      
wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh      
chmod +x Miniconda3-latest-MacOSX-x86_64.sh      
./Miniconda3-latest-MacOSX-x86_64.sh      

Add miniconda to user path / zsh

code ~/.zshrc      
export PATH="/Users/YOURUSERNAMENAMEHERE/miniconda3/bin:$PATH"      

Install GymAI / pyTorch / sklearn

// https://conda.io/miniconda.html 
conda create -n gymai2  python=2.7.9
conda activate gymai2

pip install --upgrade pip
pip install "gym[atari]"
pip install sklearn

# for pytorch
conda install -c pytorch pytorch
pip install Cython 
pip install torchvision

IMPORTANT

  1. Be sure to use python 2.7.9 to avoid missing python symbols (__PyCodecInfo_GetIncrementalDecoder)

  2. There's a hack required to get torchvision to load testing / training data used in Pytorch.swift.
    In your Users/USERNAMEHERE/miniconda3/envs/gymai2/lib/python2.7/site-packages/
    rename torchvision-0.2.1-py2.7.egg file to
    torchvision-0.2.1-py2.7.zip
    unzip files to site-packages

  3. You will need to update variable customClassPath in PyTorch.swift to point to hard coded path of project Sources folder. Why? The app at runtime will read in the NeuralNet.py class ScreenshotNeuralNet.py

Troubleshooting
Ensure conda environment is correctly activate in pre-actions of xcode schema.

Schema > Run > Pre-actions

conda activate gymai2

About

🏗PyTorch + Swift mashup

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published