Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-petrenko committed Jun 23, 2020
2 parents 8b1e817 + ca2efc8 commit 53bc6de
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,4 @@ trained_policies/**
*~

cmake-build*
envs/doom/multiplayer/tests/_vizdoom/
28 changes: 28 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
language: python
dist: bionic
python:
- "3.7"

notifications:
email: false

before_install:
- sudo apt-get update
- sudo apt-get install libboost-all-dev libsdl2-dev zlib1g-dev libbz2-dev
- sudo apt-get install libjpeg-dev libfluidsynth-dev libgme-dev libopenal-dev libmpg123-dev
- sudo apt-get install libsndfile1-dev libwildmidi-dev libgtk-3-dev timidity nasm tar chrpath

install:
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda
- source "$HOME/miniconda/etc/profile.d/conda.sh"
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda info -a
- patch environment.yml ./.travis/patchfile.patch
- conda env create -q -f environment.yml
- conda activate sample-factory

script:
- python -m unittest
31 changes: 31 additions & 0 deletions .travis/patchfile.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
7a8
> - astroid=2.4.0=py37_0
13c14
< - cudatoolkit=10.1.243=h6bb024c_0
---
> - cpuonly=1.0=0
30a32
> - isort=4.3.21=py37_0
33a36
> - lazy-object-proxy=1.4.3=py37h7b6447c_0
50a54
> - mccabe=0.6.1=py37_1
68a73
> - pylint=2.5.0=py37_1
71c76
< - pytorch=1.4.0=py3.7_cuda10.1.243_cudnn7.6.3_0
---
> - pytorch=1.5.0=py3.7_cpu_0
78c83,85
< - torchvision=0.5.0=py37_cu101
---
> - toml=0.10.0=py37h28b3542_0
> - torchvision=0.6.0=py37_cpu
> - typed-ast=1.4.1=py37h7b6447c_0
109a117
> - gym-minigrid==1.0.1
125a134,135
> - tensorflow-cpu==1.15.0
> - tensorflow-estimator==1.15.1
129a140
> - git+https://github.com/alex-petrenko/ViZDoom@doom_bot_project#egg=vizdoom
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Build Status](https://travis-ci.org/alex-petrenko/sample-factory.svg?branch=master)](https://travis-ci.org/github/alex-petrenko/sample-factory)

# Sample Factory

Codebase for high throughput asynchronous reinforcement learning.
Expand Down
14 changes: 12 additions & 2 deletions algorithms/appo/tests/test_model.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import unittest
from unittest import TestCase

import torch
Expand All @@ -11,7 +12,9 @@


class TestModel(TestCase):
def test_forward_pass(self):

@staticmethod
def forward_pass(device_type):
env_name = 'atari_breakout'
cfg = default_cfg(algo='APPO', env=env_name)
cfg.actor_critic_share_weights = True
Expand All @@ -24,7 +27,7 @@ def test_forward_pass(self):
torch.backends.cudnn.benchmark = True

actor_critic = create_actor_critic(cfg, env.observation_space, env.action_space)
device = torch.device('cuda')
device = torch.device(device_type)
actor_critic.to(device)

timing = Timing()
Expand All @@ -43,3 +46,10 @@ def test_forward_pass(self):
log.debug('Progress %d/%d', i, n)

log.debug('Timing: %s', timing)

def test_forward_pass_cpu(self):
self.forward_pass('cpu')

@unittest.skipUnless(torch.cuda.is_available(), 'This test requires a GPU')
def test_forward_pass_gpu(self):
self.forward_pass('cuda')
2 changes: 1 addition & 1 deletion envs/doom/multiplayer/doom_multiagent_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def _ensure_initialized(self):
time.sleep(0.05)

for i, worker in enumerate(self.workers):
worker.result_queue.get(timeout=5)
worker.result_queue.get(timeout=20)
worker.result_queue.task_done()
worker.task_queue.join()
except filelock.Timeout:
Expand Down

0 comments on commit 53bc6de

Please sign in to comment.