未验证 提交 fdab43b5 编写于 作者: F fwenguang 提交者: GitHub

[MLU]add mlu ci dockerfile (#39021)

* [MLU]add mlu ci dockerfile

* fix comment

* add cncl
上级 4f1fef60
......@@ -235,7 +235,7 @@ void TensorFromVector(const std::vector<T>& src,
}
#endif
#ifdef PADDLE_WITH_MLU
if (platform::is_mlu_place(dst_place)) {
else if (platform::is_mlu_place(dst_place)) { // NOLINT
memory::Copy(
dst_place, dst_ptr, src_place, src_ptr, size,
reinterpret_cast<const platform::MLUDeviceContext&>(ctx).stream());
......
......@@ -962,6 +962,23 @@ void Copy<pten::Place, pten::MLUPlace>(pten::Place dst_place, void* dst,
stream);
}
// NOTE: only for (MLUPlace) -> (CPUPlace) with mluStream.
template <>
void Copy<pten::CPUPlace, pten::Place>(pten::CPUPlace dst_place, void* dst,
pten::Place src_place, const void* src,
size_t num, mluStream stream) {
Copy(pten::Place(dst_place.GetType()), dst, src_place, src, num, stream);
}
// NOTE: only for (CPUPlace) -> (MLUPlace) with mluStream.
template <>
void Copy<pten::Place, pten::CPUPlace>(pten::Place dst_place, void* dst,
pten::CPUPlace src_place,
const void* src, size_t num,
mluStream stream) {
Copy(dst_place, dst, pten::Place(src_place.GetType()), src, num, stream);
}
#endif // PADDLE_WITH_MLU
// NOTE: Only for CPUPlace, XPUPlace and PinnedPlace.
......
......@@ -35,9 +35,7 @@ class MeanMLUKernel : public framework::OpKernel<T> {
auto stream = context.template device_context<MLUDeviceContext>().stream();
if (rank == 0) { // scalar
auto mlu_place = BOOST_GET(platform::MLUPlace, place);
memory::Copy(mlu_place, out_data, mlu_place, in_data, numel * sizeof(T),
stream);
memory::Copy(place, out_data, place, in_data, numel * sizeof(T), stream);
return;
}
......@@ -85,9 +83,7 @@ class MeanMLUGradKernel : public framework::OpKernel<T> {
auto stream = context.template device_context<MLUDeviceContext>().stream();
if (rank == 0) { // scalar
auto mlu_place = BOOST_GET(platform::MLUPlace, place);
memory::Copy(mlu_place, out_data, mlu_place, in_data, numel * sizeof(T),
stream);
memory::Copy(place, out_data, place, in_data, numel * sizeof(T), stream);
return;
}
......
IF(WITH_MLU)
cc_library(mlu_baseop SRCS mlu_baseop.cc DEPS neuware_lib)
cc_library(mlu_baseop SRCS mlu_baseop.cc DEPS neuware_lib framework_proto xxhash)
cc_test(activation_op_mlu_test SRCS activation_op_mlu_test.cc DEPS op_registry activation_op scope device_context executor)
ENDIF()
# A image for building paddle binaries
# Update CNTOOLKIT_VERSION, CNNL_VERSION and CNCL_VERSION if using other versions
#
# Build:
# - CNTOOLKIT_VERSION 2.6.5-1
# - CNNL_VERSION 1.8.3-1
# - CNCL_VERSION 1.0.2-1
#
# Download three packages from FTP (need to connect cambricon AE to get FTP url)
# - cntoolkit_2.6.5-1.ubuntu18.04_amd64.deb
# - cnnl_1.8.3-1.ubuntu18.04_amd64.deb
# - cncl_1.0.2-1.ubuntu18.04_amd64.deb
# copy them to current directory first, then run build commands
#
# For example:
#
# cd Paddle/tools/dockerfile
#
# (get cntoolkit pkg)
# (get cnnl pkg)
# (get cncl pkg)
#
# docker build -f Dockerfile.mlu \
# --build-arg CNTOOLKIT_VERSION=2.6.5-1 \
# --build-arg CNNL_VERSION=1.8.3-1 \
# --build-arg CNCL_VERSION=1.0.2-1 \
# -t paddlepaddle/paddle:latest-dev-mlu .
#
# without mlu device:
# docker run -it --network=host --pids-limit 409600 \
# paddlepaddle/paddle:latest-dev-mlu /bin/bash
#
# with mlu device:
# docker run -it --network=host --pids-limit 409600 \
# --device=/dev/cambricon_ctl --device=/dev/cambricon_dev0 \
# paddlepaddle/paddle:latest-dev-mlu /bin/bash
FROM registry.baidubce.com/paddlepaddle/paddle:latest-dev
MAINTAINER PaddlePaddle Authors <paddle-dev@baidu.com>
ENV WITH_GPU=OFF
ARG CNTOOLKIT_VERSION=2.6.5-1
ARG CNNL_VERSION=1.8.3-1
ARG CNCL_VERSION=1.0.2-1
ARG CNTOOLKIT_PKG=cntoolkit_$CNTOOLKIT_VERSION.ubuntu18.04_amd64.deb
ARG CNNL_PKG=cnnl_$CNNL_VERSION.ubuntu18.04_amd64.deb
ARG CNCL_PKG=cncl_$CNCL_VERSION.ubuntu18.04_amd64.deb
# install cntoolkit
COPY $CNTOOLKIT_PKG ./
RUN dpkg -i $CNTOOLKIT_PKG && \
apt-get update && \
apt-get install -y cnrt cnperf cnpapi cnlicense cngdb cndrv cndev cncodec cncc cnas cnbin cnstudio cnrtc cnpx && \
rm -f $CNTOOLKIT_PKG
ENV NEUWARE_HOME=/usr/local/neuware
ENV LD_LIBRARY_PATH=$NEUWARE_HOME/lib64:$LD_LIBRARY_PATH
# install cnnl
COPY $CNNL_PKG ./
RUN dpkg -i $CNNL_PKG && \
rm -f $CNNL_PKG
# install cncl
COPY $CNCL_PKG ./
RUN dpkg -i $CNCL_PKG && \
rm -f $CNCL_PKG
# Clean
RUN apt-get clean -y
EXPOSE 22
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册