mirror of https://github.com/Jittor/Jittor
redirect jupyter outputs
This commit is contained in:
parent
2ed7ae6aec
commit
c1e0861446
|
@ -17,6 +17,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "utils/log.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
@ -103,10 +105,10 @@ template <typename T>
|
|||
void check(T result, char const *const func, const char *const file,
|
||||
int const line) {
|
||||
if (result) {
|
||||
fprintf(stderr, "CUDA error at %s:%d code=%d(%s) \"%s\" \n", file, line,
|
||||
static_cast<unsigned int>(result), _cudaGetErrorEnum(result), func);
|
||||
DEVICE_RESET
|
||||
throw std::runtime_error("CUDA error");
|
||||
LOGf << "CUDA error at" << file >> ":" >> line << " code="
|
||||
>> static_cast<unsigned int>(result) >> "(" << _cudaGetErrorEnum(result) << ")"
|
||||
<< func;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,13 +125,10 @@ inline void __getLastCudaError(const char *errorMessage, const char *file,
|
|||
cudaError_t err = cudaGetLastError();
|
||||
|
||||
if (cudaSuccess != err) {
|
||||
fprintf(stderr,
|
||||
"%s(%i) : getLastCudaError() CUDA error :"
|
||||
" %s : (%d) %s.\n",
|
||||
file, line, errorMessage, static_cast<int>(err),
|
||||
cudaGetErrorString(err));
|
||||
DEVICE_RESET
|
||||
exit(EXIT_FAILURE);
|
||||
LOGf << "CUDA error at" << file >> ":" >> line << " code="
|
||||
>> static_cast<unsigned int>(err) >> "(" << _cudaGetErrorEnum(err) << ")"
|
||||
<< errorMessage;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,11 +141,10 @@ inline void __printLastCudaError(const char *errorMessage, const char *file,
|
|||
cudaError_t err = cudaGetLastError();
|
||||
|
||||
if (cudaSuccess != err) {
|
||||
fprintf(stderr,
|
||||
"%s(%i) : getLastCudaError() CUDA error :"
|
||||
" %s : (%d) %s.\n",
|
||||
file, line, errorMessage, static_cast<int>(err),
|
||||
cudaGetErrorString(err));
|
||||
DEVICE_RESET
|
||||
LOGf << "CUDA error at" << file >> ":" >> line << " code="
|
||||
>> static_cast<unsigned int>(err) >> "(" << _cudaGetErrorEnum(err) << ")"
|
||||
<< errorMessage;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -20,10 +20,8 @@ void throw_mpi_error(int result,
|
|||
char const *const func, const char *const file, int const line) {
|
||||
int resultlen;
|
||||
MPI_Error_string(result, jt_mpi_err_buffer, &resultlen);
|
||||
fprintf(stderr, "MPI error at %s:%d code=%d(%s) \"%s\" \n",
|
||||
file, line,
|
||||
static_cast<unsigned int>(result), jt_mpi_err_buffer, func);
|
||||
throw std::runtime_error("MPI error");
|
||||
LOGf << "MPI error at " >> file >> ":" >> line << "code="
|
||||
>> result >> '(' >> jt_mpi_err_buffer >> ')' << func;
|
||||
}
|
||||
|
||||
namespace jittor {
|
||||
|
|
|
@ -51,7 +51,7 @@ for mdname in all_md:
|
|||
else:
|
||||
cell["cell_type"] = "code"
|
||||
cell["outputs"] = []
|
||||
cell["execution_count"] = None
|
||||
cell["execution_count"] = 0
|
||||
cells.append(cell)
|
||||
ipynb = {
|
||||
"cells":cells,
|
||||
|
|
|
@ -827,6 +827,7 @@ addr2line_path = try_find_exe('addr2line')
|
|||
has_pybt = check_pybt(gdb_path, python_path)
|
||||
|
||||
cc_flags += " -Wall -Werror -Wno-unknown-pragmas -std=c++14 -fPIC -march=native "
|
||||
cc_flags += " -fdiagnostics-color=always "
|
||||
link_flags = " -lstdc++ -ldl -shared "
|
||||
core_link_flags = ""
|
||||
opt_flags = ""
|
||||
|
@ -874,6 +875,7 @@ if has_cuda:
|
|||
nvcc_flags = nvcc_flags.replace("-march", "-Xcompiler -march")
|
||||
nvcc_flags = nvcc_flags.replace("-Werror", "")
|
||||
nvcc_flags = nvcc_flags.replace("-fPIC", "-Xcompiler -fPIC")
|
||||
nvcc_flags = nvcc_flags.replace("-fdiagnostics", "-Xcompiler -fdiagnostics")
|
||||
nvcc_flags += f" -x cu --cudart=shared -ccbin='{cc_path}' --use_fast_math "
|
||||
# nvcc warning is noise
|
||||
nvcc_flags += " -w "
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <memory>
|
||||
|
||||
namespace jittor {
|
||||
|
||||
|
|
|
@ -280,12 +280,26 @@ bool check_vlog(const char* fileline, int verbose) {
|
|||
return verbose <= log_v;
|
||||
}
|
||||
|
||||
int system_popen(const char* cmd) {
|
||||
static char buf[BUFSIZ];
|
||||
static string cmd2;
|
||||
cmd2 = cmd;
|
||||
cmd2 += " 2>&1 ";
|
||||
FILE *ptr = popen(cmd2.c_str(), "r");
|
||||
if (!ptr) return -1;
|
||||
while (fgets(buf, BUFSIZ, ptr) != NULL) {
|
||||
std::cout << buf;
|
||||
std::cout.flush();
|
||||
}
|
||||
return pclose(ptr);
|
||||
}
|
||||
|
||||
void system_with_check(const char* cmd) {
|
||||
auto ret = system(cmd);
|
||||
ASSERT(ret!=-1) << "Run cmd failed:" << cmd <<
|
||||
"\nreturn -1. This might be an overcommit issue."
|
||||
auto ret = system_popen(cmd);
|
||||
CHECK(ret!=-1) << "Run cmd failed:" << cmd <<
|
||||
"\nreturn -1. This might be an overcommit issue or out of memory."
|
||||
<< "Try : echo 1 >/proc/sys/vm/overcommit_memory";
|
||||
ASSERTop(ret,==,0) << "Run cmd failed:" << cmd;
|
||||
CHECKop(ret,==,0) << "Run cmd failed:" << cmd;
|
||||
}
|
||||
|
||||
std::thread log_thread(log_main);
|
||||
|
|
Loading…
Reference in New Issue