Skip to content

Commit

Permalink
Merge pull request #29 from albarji/bugfix/gpudetectfail
Browse files Browse the repository at this point in the history
Capture errors while detecting GPUs
  • Loading branch information
albarji authored Oct 27, 2018
2 parents f5ee2d5 + fd1b0f7 commit acc490b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ RUN curl -o Miniconda3-latest-Linux-x86_64.sh https://repo.continuum.io/minicond
&& ./Miniconda3-latest-Linux-x86_64.sh -b -p "${MINICONDA_HOME}" \
&& rm Miniconda3-latest-Linux-x86_64.sh
COPY conda.txt conda.txt
RUN conda install -y --file=conda.txt
RUN conda clean -y -i -l -p -t && \
RUN conda install -y --file=conda.txt && \
conda clean -y -i -l -p -t && \
rm -f conda.txt
COPY pip.txt pip.txt
RUN pip install -r pip.txt && \
Expand Down
2 changes: 1 addition & 1 deletion conda.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
numpy
numpy==1.15.3
8 changes: 6 additions & 2 deletions neuralstyle/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,11 @@ def targetshape(content, size=None):

def gpuname():
"""Returns the model name of the first available GPU"""
gpus = GPUtil.getGPUs()
try:
gpus = GPUtil.getGPUs()
except:
LOGGER.warning("Unable to detect GPU model. Is your GPU configured? Are you running with nvidia-docker?")
return "UNKNOWN"
if len(gpus) == 0:
raise ValueError("No GPUs detected in the system")
return gpus[0].name
Expand All @@ -365,6 +369,6 @@ def maxtile(alg="gatys"):
"""
gname = gpuname()
if gname not in GPUCONFIG:
LOGGER.warning("Unknown GPU model %s, will use default tiling parameters")
LOGGER.warning(f"Unknown GPU model {gname}, will use default tiling parameters")
gname = "default"
return GPUCONFIG[gname][alg]
2 changes: 1 addition & 1 deletion pip.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
gputil
gputil==1.3.0

0 comments on commit acc490b

Please sign in to comment.