FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Merge pull request #484 from Ishitori/master · RTDataScience/docker-python@8dc2d4e · GitHub

Commit 8dc2d4e

Browse files
authored
Merge pull request Kaggle#484 from Ishitori/master
Add MXNet GPU + GluonNLP and GluonCV toolkits
2 parents e65f73e + 2def008 commit 8dc2d4e

4 files changed

Lines changed: 42 additions & 9 deletions

File tree

‎Dockerfile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ RUN apt-get -y install zlib1g-dev liblcms2-dev libwebp-dev libgeos-dev && \
140140
# MXNet
141141
pip install mxnet && \
142142
pip install --upgrade numpy && \
143+
pip install gluonnlp && \
144+
pip install gluoncv && \
143145
# h2o (requires java)
144146
# requires java
145147
apt-get install -y default-jdk && \

‎gpu.Dockerfile‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ RUN pip uninstall -y tensorflow && \
5252
conda install -y pytorch torchvision cudatoolkit=9.2 -c pytorch && \
5353
/tmp/clean-layer.sh
5454

55+
RUN pip uninstall -y mxnet && \
56+
pip install mxnet-cu92
57+
5558
# Install GPU-only packages
5659
RUN pip install pycuda && \
5760
pip install cupy-cuda92 && \

‎tests/test_mxnet.py‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import unittest
2+
from common import gpu_test
3+
4+
import mxnet as mx
5+
from gluonnlp import Vocab
6+
from gluonnlp.data import count_tokens
7+
8+
from gluoncv.data.transforms.image import imresize
9+
10+
11+
class TestMxNet(unittest.TestCase):
12+
def test_array(self):
13+
x = mx.nd.array([[1, 2, 3], [4, 5, 6]])
14+
15+
self.assertEqual((2, 3), x.shape)
16+
17+
@gpu_test
18+
def test_array_gpu(self):
19+
x = mx.nd.array([2, 2, 2], ctx=mx.gpu(0))
20+
y = mx.nd.array([1, 1, 1], ctx=mx.gpu(0))
21+
self.assertEqual(3, ((x - y).sum().asscalar()))
22+
23+
def test_gluon_nlp(self):
24+
# get corpus statistics
25+
counter = count_tokens(['alpha', 'beta', 'gamma', 'beta'])
26+
# create Vocab
27+
vocab = Vocab(counter)
28+
# find index based on token
29+
self.assertEqual(4, vocab['beta'])
30+
31+
def test_gluon_cv(self):
32+
# create fake RGB image of 300x300 of shape: Height x Width x Channel as OpenCV expects
33+
img = mx.random.uniform(0, 255, (300, 300, 3)).astype('uint8')
34+
# resize image to 200x200. This call uses OpenCV
35+
# GluonCV is not of much use if OpenCV is not there or fails
36+
img = imresize(img, 200, 200)
37+
self.assertEqual((200, 200, 3), img.shape)

‎tests/text_mxnet.py‎

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL