Skip to content

Commit

Permalink
Backend paddle:Switch to version 2.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lijialin03 committed Jan 5, 2024
1 parent d342b4d commit 4665603
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
10 changes: 8 additions & 2 deletions deepxde/backend/paddle/tensor.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
"""paddle backend implementation"""
import sys
from packaging.version import Version

import paddle

if Version(paddle.__version__) != Version("0.0.0"):
raise RuntimeError("DeepXDE requires PaddlePaddle==0.0.0(develop).")
if Version(paddle.__version__) < Version("2.6.0"):
print(
"Error may occur when running some examples with PaddlePaddle<2.6.0.",
"It is recommended to use PaddlePaddle>=2.6.0 or PaddlePaddle==0.0.0(develop)",
file=sys.stderr,
flush=True,
)

if paddle.device.is_compiled_with_cuda():
paddle.device.set_device("gpu")
Expand Down
30 changes: 15 additions & 15 deletions deepxde/backend/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ def get_cuda(platform):
cuda_verion (str) or None
"""
if platform == "linux":
cuda_list = [101, 102, 110, 111, 112, 116, 117, 118, 120]
cuda_list = [112, 116, 117, 120]
elif platform == "windows":
cuda_list = [101, 102, 110, 111, 112, 113, 114, 115, 116, 117, 118, 120]
cuda_list = [112, 116, 117, 120]
nvcc_text = os.popen("nvcc -V").read()
if nvcc_text != "":
cuda_version = nvcc_text.split("Cuda compilation tools, release ")[-1].split(
Expand Down Expand Up @@ -189,7 +189,7 @@ def check_avx(platform):

if avx_text1 == "" and avx_text2 == "":
sys.exit(
"Your machine doesn't support AVX, which is required by PaddlePaddle (develop version). "
"Your machine doesn't support AVX, which is required by PaddlePaddle. "
"Paddle installation stopped.\n"
"Please use another backend."
)
Expand All @@ -215,32 +215,36 @@ def generate_cmd(py_exec, platform, cuda_version=None, has_rocm=False):
"""
if platform == "darwin":
print(
"Paddle can only be installed in macOS with CPU version now. ",
"Paddle can only be installed in macOS with CPU version now.",
"Installing CPU version...",
file=sys.stderr,
flush=True,
)
cmd = "{}{}{}".format(
cmd = "{}{}".format(
py_exec,
" -m pip install paddlepaddle==0.0.0 -f ",
"https://www.paddlepaddle.org.cn/whl/mac/cpu/develop.html",
" -m pip install paddlepaddle==2.6.0 -i https://pypi.tuna.tsinghua.edu.cn/simple",
)
return cmd

if cuda_version is not None:
print(f"Installing CUDA {cuda_version} version...", file=sys.stderr, flush=True)
cmd = "{}{}{}{}{}{}".format(
py_exec,
" -m pip install paddlepaddle-gpu==0.0.0.post",
" -m pip install paddlepaddle-gpu==2.6.0.post",
int(float(cuda_version) * 10),
" -f https://www.paddlepaddle.org.cn/whl/",
platform,
"/gpu/develop.html",
"/mkl/avx/stable.html",
)
return cmd

if platform == "linux" and has_rocm:
print("Installing ROCm4.0 version...", file=sys.stderr, flush=True)
print(
"Paddle can only be installed in ROCm4.0 with develop version now.",
"Installing ROCm4.0 version...",
file=sys.stderr,
flush=True,
)
cmd = "{}{}{}".format(
py_exec,
" -m pip install --pre paddlepaddle-rocm -f ",
Expand All @@ -251,12 +255,8 @@ def generate_cmd(py_exec, platform, cuda_version=None, has_rocm=False):
print("Installing CPU version...", file=sys.stderr, flush=True)
cmd = "{}{}".format(
py_exec,
" -m pip install paddlepaddle==0.0.0 -f https://www.paddlepaddle.org.cn/whl/",
" -m pip install paddlepaddle==2.6.0 -i https://pypi.tuna.tsinghua.edu.cn/simple",
)
if platform == "windows":
cmd += "windows/cpu-mkl-avx/develop.html"
elif platform == "linux":
cmd += "linux/cpu-mkl/develop.html"
return cmd


Expand Down

0 comments on commit 4665603

Please sign in to comment.