Skip to content

Commit

Permalink
ARROW-17423: [CI][C++] Fix building CUDA docker images (#13896)
Browse files Browse the repository at this point in the history
* Update the CUDA runtime version as CUDA 9.1 images are not available anymore
* Fix passing child command arguments to "docker run"

Checked locally under a Ubuntu 20.04 host with:
```
UBUNTU=18.04 archery --debug docker run ubuntu-cuda-cpp
UBUNTU=20.04 archery --debug docker run ubuntu-cuda-cpp
```

Authored-by: Antoine Pitrou <antoine@python.org>
Signed-off-by: Antoine Pitrou <antoine@python.org>
  • Loading branch information
pitrou committed Aug 17, 2022
1 parent 050876c commit f6127fc
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ UBUNTU=20.04

# Default versions for various dependencies
CLANG_TOOLS=12
CUDA=9.1
CUDA=11.0.3
DASK=latest
DOTNET=6.0
GCC_VERSION=""
Expand Down
18 changes: 6 additions & 12 deletions dev/archery/archery/docker/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
# under the License.

import os
import re
import shlex
import subprocess
from io import StringIO

from dotenv import dotenv_values
from ruamel.yaml import YAML

from ..utils.command import Command, default_bin
from ..utils.source import arrow_path
from ..compat import _ensure_path


Expand All @@ -42,12 +43,6 @@ def flatten(node, parents=None):
raise TypeError(node)


def _sanitize_command(cmd):
if isinstance(cmd, list):
cmd = " ".join(cmd)
return re.sub(r"\s+", " ", cmd)


_arch_short_mapping = {
'arm64v8': 'arm64',
}
Expand Down Expand Up @@ -294,7 +289,7 @@ def _build(service, use_cache):

args.extend([
'--output', 'type=docker',
'-f', service['build']['dockerfile'],
'-f', arrow_path(service['build']['dockerfile']),
'-t', service['image'],
service['build'].get('context', '.')
])
Expand All @@ -306,7 +301,7 @@ def _build(service, use_cache):
for img in cache_from:
args.append('--cache-from="{}"'.format(img))
args.extend([
'-f', service['build']['dockerfile'],
'-f', arrow_path(service['build']['dockerfile']),
'-t', service['image'],
service['build'].get('context', '.')
])
Expand Down Expand Up @@ -381,10 +376,9 @@ def run(self, service_name, command=None, *, env=None, volumes=None,
if command is not None:
args.append(command)
else:
# replace whitespaces from the preformatted compose command
cmd = _sanitize_command(service.get('command', ''))
cmd = service.get('command', '')
if cmd:
args.append(cmd)
args.extend(shlex.split(cmd))

# execute as a plain docker cli command
self._execute_docker('run', '--rm', *args)
Expand Down
2 changes: 1 addition & 1 deletion dev/archery/archery/docker/tests/test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def test_image_with_gpu(arrow_compose_path):
"-e", "OTHER_ENV=2",
"-v", "/host:/container:rw",
"org/ubuntu-cuda",
'/bin/bash -c "echo 1 > /tmp/dummy && cat /tmp/dummy"'
"/bin/bash", "-c", "echo 1 > /tmp/dummy && cat /tmp/dummy",
]
]
with assert_docker_calls(compose, expected_calls):
Expand Down
4 changes: 2 additions & 2 deletions dev/archery/archery/integration/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
from .tester_java import JavaTester
from .tester_js import JSTester
from .tester_csharp import CSharpTester
from .util import (ARROW_ROOT_DEFAULT, guid, SKIP_ARROW, SKIP_FLIGHT,
printer)
from .util import guid, SKIP_ARROW, SKIP_FLIGHT, printer
from ..utils.source import ARROW_ROOT_DEFAULT
from . import datagen


Expand Down
3 changes: 2 additions & 1 deletion dev/archery/archery/integration/tester_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import subprocess

from .tester import Tester
from .util import run_cmd, ARROW_ROOT_DEFAULT, log
from .util import run_cmd, log
from ..utils.source import ARROW_ROOT_DEFAULT


_EXE_PATH = os.environ.get(
Expand Down
3 changes: 2 additions & 1 deletion dev/archery/archery/integration/tester_csharp.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
import os

from .tester import Tester
from .util import run_cmd, ARROW_ROOT_DEFAULT, log
from .util import run_cmd, log
from ..utils.source import ARROW_ROOT_DEFAULT


_EXE_PATH = os.path.join(
Expand Down
3 changes: 2 additions & 1 deletion dev/archery/archery/integration/tester_java.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import subprocess

from .tester import Tester
from .util import run_cmd, ARROW_ROOT_DEFAULT, log
from .util import run_cmd, log
from ..utils.source import ARROW_ROOT_DEFAULT


def load_version_from_pom():
Expand Down
4 changes: 3 additions & 1 deletion dev/archery/archery/integration/tester_js.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import os

from .tester import Tester
from .util import run_cmd, ARROW_ROOT_DEFAULT, log
from .util import run_cmd, log
from ..utils.source import ARROW_ROOT_DEFAULT


_EXE_PATH = os.path.join(ARROW_ROOT_DEFAULT, 'js/bin')
_VALIDATE = os.path.join(_EXE_PATH, 'integration.js')
Expand Down
3 changes: 2 additions & 1 deletion dev/archery/archery/integration/tester_rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import subprocess

from .tester import Tester
from .util import run_cmd, ARROW_ROOT_DEFAULT, log
from .util import run_cmd, log
from ..utils.source import ARROW_ROOT_DEFAULT


_EXE_PATH = os.path.join(ARROW_ROOT_DEFAULT, "rust/target/debug")
Expand Down
6 changes: 0 additions & 6 deletions dev/archery/archery/integration/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import contextlib
import io
import os
import random
import socket
import subprocess
Expand All @@ -36,11 +35,6 @@ def guid():
SKIP_ARROW = 'arrow'
SKIP_FLIGHT = 'flight'

ARROW_ROOT_DEFAULT = os.environ.get(
'ARROW_ROOT',
os.path.abspath(__file__).rsplit("/", 5)[0]
)


class _Printer:
"""
Expand Down
13 changes: 13 additions & 0 deletions dev/archery/archery/utils/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@
from .git import git


ARROW_ROOT_DEFAULT = os.environ.get(
'ARROW_ROOT',
Path(__file__).resolve().parents[4]
)


def arrow_path(path):
"""
Return full path to a file given its path inside the Arrow repo.
"""
return os.path.join(ARROW_ROOT_DEFAULT, path)


class InvalidArrowSource(Exception):
pass

Expand Down
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,14 @@ services:
ulimits: *ulimits
environment:
<<: *ccache
ARROW_BUILD_STATIC: "OFF"
ARROW_CUDA: "ON"
ARROW_GANDIVA: "OFF"
ARROW_GCS: "OFF"
ARROW_ORC: "OFF"
ARROW_S3: "OFF"
ARROW_SUBSTRAIT: "OFF"
ARROW_WITH_OPENTELEMETRY: "OFF"
volumes: *ubuntu-volumes
command: *cpp-command

Expand Down

0 comments on commit f6127fc

Please sign in to comment.