Skip to content

Commit 7bc6d62

Browse files
committed
Merge branch 'master' into cub_fp16_support
2 parents 188f350 + bb3205c commit 7bc6d62

227 files changed

Lines changed: 15299 additions & 4125 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.mergify.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
pull_request_rules:
2+
- name: Auto merge
3+
conditions:
4+
- "#changes-requested-reviews-by=0"
5+
- label=st:test-and-merge
6+
- status-success=Jenkins
7+
- status-success=continuous-integration/travis-ci/pr
8+
- status-success=pfn-public-ci/cupy.py2.cv.examples
9+
- status-success=pfn-public-ci/cupy.py2.cv.gpu
10+
- status-success=pfn-public-ci/cupy.py3.amd
11+
- status-success=pfn-public-ci/cupy.py3.cv.examples
12+
- status-success=pfn-public-ci/cupy.py3.cv.gpu
13+
actions:
14+
merge:
15+
method: merge
16+
strict: false # strict mode and manually-triggered CIs do not get along

.pfnci/config.pbtxt

Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -137,64 +137,19 @@ configs {
137137
command: "true"
138138
}
139139
}
140+
141+
# ChainerCV's tests are disabled in the master branch, but configs can be removed
142+
# only after removing web hooks.
140143
configs {
141144
key: "cupy.py3.cv.gpu"
142145
value {
143-
requirement {
144-
cpu: 4
145-
memory: 24
146-
disk: 10
147-
gpu: 1
148-
}
149-
time_limit {
150-
seconds: 1800
151-
}
152-
checkout_strategy {
153-
include_dot_git: true
154-
}
155-
command: "git clone https://github.com/chainer/chainercv.git --depth 1 && sh chainercv/.pfnci/tests_gpu.sh"
156-
environment_variables {
157-
key: "REPOSITORY"
158-
value: "cupy"
159-
}
160-
environment_variables {
161-
key: "PYTHON"
162-
value: "3"
163-
}
164-
environment_variables {
165-
key: "OPTIONAL_MODULES"
166-
value: "1"
167-
}
146+
command: "true"
168147
}
169148
}
170149
configs {
171150
key: "cupy.py3.cv.examples"
172151
value {
173-
requirement {
174-
cpu: 6
175-
memory: 36
176-
disk: 10
177-
gpu: 2
178-
}
179-
time_limit {
180-
seconds: 3600
181-
}
182-
checkout_strategy {
183-
include_dot_git: true
184-
}
185-
command: "git clone https://github.com/chainer/chainercv.git --depth 1 && sh chainercv/.pfnci/examples_tests.sh"
186-
environment_variables {
187-
key: "REPOSITORY"
188-
value: "cupy"
189-
}
190-
environment_variables {
191-
key: "PYTHON"
192-
value: "3"
193-
}
194-
environment_variables {
195-
key: "OPTIONAL_MODULES"
196-
value: "1"
197-
}
152+
command: "true"
198153
}
199154
}
200155

.pfnci/py27and35.Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ RUN git clone --depth=1 https://github.com/chainer/xpytest.git /xpytest
33
RUN cd /xpytest && \
44
go build -o /usr/local/bin/xpytest ./cmd/xpytest
55

6-
FROM nvidia/cuda:9.2-cudnn7-devel-ubuntu16.04
6+
FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu16.04
77

88
RUN apt-get update -y && \
99
apt-get install -y --no-install-recommends \
@@ -12,16 +12,20 @@ RUN apt-get update -y && \
1212
wget git g++ make && \
1313
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
1414

15+
RUN wget 'https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/libcutensor1_1.0.0-1_amd64.deb' && \
16+
dpkg -i 'libcutensor1_1.0.0-1_amd64.deb' && \
17+
rm 'libcutensor1_1.0.0-1_amd64.deb'
18+
1519
RUN python3.5 -m pip install --upgrade pip setuptools
1620
RUN python2.7 -m pip install --upgrade pip setuptools
1721

1822
RUN python3.5 -m pip install \
1923
'cython>=0.28.0' 'pytest==4.1.1' 'pytest-xdist==1.26.1' \
20-
mock setuptools filelock 'numpy>=1.9.0' 'protobuf>=3.0.0' 'six>=1.9.0'
24+
mock setuptools filelock 'numpy>=1.9.0' 'protobuf>=3.0.0'
2125

2226
RUN python2.7 -m pip install \
2327
'cython>=0.28.0' 'pytest==4.1.1' 'pytest-xdist==1.26.1' \
24-
mock setuptools filelock 'protobuf>=3.0.0' 'six>=1.9.0'
28+
mock setuptools filelock 'protobuf>=3.0.0'
2529

2630
# Newer versions of numpy and more-itertools no longer support python2.
2731
RUN python2.7 -m pip install 'numpy<=1.16.5' 'more-itertools<=5.0.0'

.pfnci/py37.Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,25 @@ RUN git clone --depth=1 https://github.com/chainer/xpytest.git /xpytest
33
RUN cd /xpytest && \
44
go build -o /usr/local/bin/xpytest ./cmd/xpytest
55

6-
FROM nvidia/cuda:9.2-cudnn7-devel-ubuntu18.04
6+
FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04
77

88
RUN apt-get update -y && \
99
apt-get install -y --no-install-recommends \
1010
python3.7-dev python3-pip python3-wheel python3-setuptools \
1111
wget git g++ make && \
1212
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
1313

14+
RUN wget 'https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/libcutensor1_1.0.0-1_amd64.deb' &&
15+
dpkg -i 'libcutensor1_1.0.0-1_amd64.deb' &&
16+
rm 'libcutensor1_1.0.0-1_amd64.deb'
17+
1418
RUN python3.7 -m pip install --upgrade pip setuptools
1519

1620
# NOTE: protobuf version is fixed because of deprecation warning in 3.7.0:
1721
# https://github.com/protocolbuffers/protobuf/issues/5865
1822
RUN python3.7 -m pip install \
1923
'cython>=0.28.0' \
2024
'pytest==4.1.1' 'pytest-xdist==1.26.1' mock setuptools \
21-
filelock 'numpy>=1.9.0' 'protobuf==3.6.1' 'six>=1.9.0'
25+
filelock 'numpy>=1.9.0' 'protobuf==3.6.1'
2226

2327
COPY --from=xpytest /usr/local/bin/xpytest /usr/local/bin/xpytest

.pfnci/script.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ prepare_docker() {
138138
# base development branch.
139139
is_known_base_branch() {
140140
local branch="${1##refs/heads/}"
141-
for BASE_BRANCH in master v6; do
141+
for BASE_BRANCH in master v7; do
142142
if [ "${branch}" = "${BASE_BRANCH}" ]; then
143143
return 0
144144
fi
@@ -148,9 +148,10 @@ is_known_base_branch() {
148148

149149
# get_base_branch returns the base development branch for the current HEAD.
150150
get_base_branch() {
151-
for BASE_BRANCH in master v6; do
152-
run git merge-base --is-ancestor "origin/${BASE_BRANCH}" HEAD && echo "${BASE_BRANCH}" && return 0
151+
for BASE_BRANCH in master v7; do
152+
git merge-base --is-ancestor "origin/${BASE_BRANCH}" HEAD && echo "${BASE_BRANCH}" && return 0
153153
done
154+
echo "Base branch of HEAD is not valid." >&2
154155
return 1
155156
}
156157

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ cache:
55
- ccache
66

77
python:
8-
- "3.4"
98
- "3.5"
109

10+
env:
11+
- CUPY_CI=travis
12+
1113
install:
1214
- pip install -U pip wheel
1315
- pip install cython

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ $ pip install cupy-cuda100
4444
(Binary Package for CUDA 10.1)
4545
$ pip install cupy-cuda101
4646

47+
(Binary Package for CUDA 10.2)
48+
$ pip install cupy-cuda102
49+
4750
(Source Package)
4851
$ pip install cupy
4952
```

appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ environment:
2727
PYTHON_VERSION: "3.6.x"
2828
PYTHON_ARCH: "64"
2929

30+
CUPY_CI: appveyor
31+
3032
install:
3133
- ECHO "Filesystem root:"
3234
- ps: "ls \"C:/\""

cupy/__init__.py

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
from __future__ import division
21
import functools
32
import sys
43
import warnings
54

65
import numpy
7-
import six
86

7+
from cupy import _environment
98
from cupy import _version
109

1110

11+
if sys.platform.startswith('win32') and (3, 8) <= sys.version_info: # NOQA
12+
_environment._setup_win32_dll_directory() # NOQA
13+
14+
1215
try:
1316
with warnings.catch_warnings():
1417
warnings.filterwarnings('ignore', category=ImportWarning,
1518
message='can\'t resolve package from __spec__')
1619
from cupy import core # NOQA
17-
except ImportError:
20+
except ImportError as e:
1821
# core is a c-extension module.
1922
# When a user cannot import core, it represents that CuPy is not correctly
2023
# built.
@@ -34,7 +37,7 @@
3437
3538
original error: {}'''.format(exc_info[1])) # NOQA
3639

37-
six.reraise(ImportError, ImportError(msg), exc_info[2])
40+
raise ImportError(msg) from e
3841

3942

4043
from cupy import cuda
@@ -59,7 +62,7 @@ def is_available():
5962
from cupy import manipulation # NOQA
6063
from cupy import padding # NOQA
6164
from cupy import random # NOQA
62-
from cupy import sorting # NOQA
65+
from cupy import _sorting # NOQA
6366
from cupy import sparse # NOQA
6467
from cupy import statistics # NOQA
6568
from cupy import testing # NOQA # NOQA
@@ -498,12 +501,12 @@ def base_repr(number, base=2, padding=0): # NOQA (needed to avoid redefinition
498501
from cupy.logic.truth import isin # NOQA
499502

500503

501-
def isscalar(num):
504+
def isscalar(element):
502505
"""Returns True if the type of num is a scalar type.
503506
504507
.. seealso:: :func:`numpy.isscalar`
505508
"""
506-
return numpy.isscalar(num)
509+
return numpy.isscalar(element)
507510

508511

509512
from cupy.logic.ops import logical_and # NOQA
@@ -599,7 +602,8 @@ def isscalar(num):
599602
from cupy.math.arithmetic import true_divide # NOQA
600603

601604
from cupy.math.arithmetic import angle # NOQA
602-
from cupy.math.arithmetic import conj # NOQA
605+
from cupy.math.arithmetic import conjugate as conj # NOQA
606+
from cupy.math.arithmetic import conjugate # NOQA
603607
from cupy.math.arithmetic import imag # NOQA
604608
from cupy.math.arithmetic import real # NOQA
605609

@@ -632,22 +636,23 @@ def isscalar(num):
632636
# -----------------------------------------------------------------------------
633637
# Sorting, searching, and counting
634638
# -----------------------------------------------------------------------------
635-
from cupy.sorting.count import count_nonzero # NOQA
636-
from cupy.sorting.search import flatnonzero # NOQA
637-
from cupy.sorting.search import nonzero # NOQA
639+
from cupy._sorting.count import count_nonzero # NOQA
638640

639-
from cupy.sorting.search import where # NOQA
640-
from cupy.sorting.search import argmax # NOQA
641-
from cupy.sorting.search import nanargmax # NOQA
642-
from cupy.sorting.search import argmin # NOQA
643-
from cupy.sorting.search import nanargmin # NOQA
641+
from cupy._sorting.search import argmax # NOQA
642+
from cupy._sorting.search import argmin # NOQA
643+
from cupy._sorting.search import flatnonzero # NOQA
644+
from cupy._sorting.search import nanargmax # NOQA
645+
from cupy._sorting.search import nanargmin # NOQA
646+
from cupy._sorting.search import nonzero # NOQA
647+
from cupy._sorting.search import searchsorted # NOQA
648+
from cupy._sorting.search import where # NOQA
644649

645-
from cupy.sorting.sort import argpartition # NOQA
646-
from cupy.sorting.sort import argsort # NOQA
647-
from cupy.sorting.sort import lexsort # NOQA
648-
from cupy.sorting.sort import msort # NOQA
649-
from cupy.sorting.sort import partition # NOQA
650-
from cupy.sorting.sort import sort # NOQA
650+
from cupy._sorting.sort import argpartition # NOQA
651+
from cupy._sorting.sort import argsort # NOQA
652+
from cupy._sorting.sort import lexsort # NOQA
653+
from cupy._sorting.sort import msort # NOQA
654+
from cupy._sorting.sort import partition # NOQA
655+
from cupy._sorting.sort import sort # NOQA
651656

652657
# -----------------------------------------------------------------------------
653658
# Statistics
@@ -662,6 +667,7 @@ def isscalar(num):
662667
from cupy.statistics.order import nanmax # NOQA
663668
from cupy.statistics.order import nanmin # NOQA
664669
from cupy.statistics.order import percentile # NOQA
670+
from cupy.statistics.order import ptp # NOQA
665671

666672
from cupy.statistics.meanvar import average # NOQA
667673
from cupy.statistics.meanvar import mean # NOQA
@@ -672,6 +678,7 @@ def isscalar(num):
672678
from cupy.statistics.meanvar import nanvar # NOQA
673679

674680
from cupy.statistics.histogram import bincount # NOQA
681+
from cupy.statistics.histogram import digitize # NOQA
675682
from cupy.statistics.histogram import histogram # NOQA
676683

677684
# -----------------------------------------------------------------------------
@@ -689,7 +696,7 @@ def isscalar(num):
689696
from cupy.core import ElementwiseKernel # NOQA
690697
from cupy.core import RawKernel # NOQA
691698
from cupy.core import RawModule # NOQA
692-
from cupy.core import ReductionKernel # NOQA
699+
from cupy.core._reduction import ReductionKernel # NOQA
693700

694701
# -----------------------------------------------------------------------------
695702
# DLPack
@@ -805,18 +812,3 @@ def show_config():
805812
"""Prints the current runtime configuration to standard output."""
806813
sys.stdout.write(str(_cupyx.get_runtime_info()))
807814
sys.stdout.flush()
808-
809-
810-
# -----------------------------------------------------------------------------
811-
# Warning for Python 2 users
812-
# -----------------------------------------------------------------------------
813-
if sys.version_info[:1] == (2,):
814-
warnings.warn('''
815-
--------------------------------------------------------------------------------
816-
CuPy is going to stop supporting Python 2 in v7.x releases.
817-
818-
Future releases of CuPy v7.x will not run on Python 2.
819-
If you need to continue using Python 2, consider using CuPy v6.x, which
820-
will be the last version that runs on Python 2.
821-
--------------------------------------------------------------------------------
822-
''') # NOQA

cupy/_environment.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""
2+
This file must not depend on any other CuPy modules.
3+
"""
4+
5+
import os
6+
import os.path
7+
8+
9+
_cuda_path = None
10+
11+
12+
def get_cuda_path():
13+
global _cuda_path
14+
if _cuda_path is None:
15+
_cuda_path = os.getenv('CUDA_PATH', None)
16+
if _cuda_path is not None:
17+
return _cuda_path
18+
19+
for p in os.getenv('PATH', '').split(os.pathsep):
20+
for cmd in ('nvcc', 'nvcc.exe'):
21+
nvcc_path = os.path.join(p, cmd)
22+
if not os.path.exists(nvcc_path):
23+
continue
24+
nvcc_dir = os.path.dirname(os.path.abspath(nvcc_path))
25+
_cuda_path = os.path.normpath(os.path.join(nvcc_dir, '..'))
26+
return _cuda_path
27+
28+
if os.path.exists('/usr/local/cuda'):
29+
_cuda_path = '/usr/local/cuda'
30+
31+
return _cuda_path
32+
33+
34+
def _setup_win32_dll_directory():
35+
cuda_path = get_cuda_path()
36+
if cuda_path is None:
37+
raise RuntimeError('CUDA path could not be detected.')
38+
os.add_dll_directory(os.path.join(cuda_path, 'bin'))

0 commit comments

Comments
 (0)