From aa3d8aca86a13664691a0623a7b4f7d089674e0a Mon Sep 17 00:00:00 2001 From: Aleksa Gordic Date: Fri, 7 Jun 2024 17:06:53 +0200 Subject: [PATCH 1/2] Minor fix - better handling of out log dir --- train_gpt2.cu | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/train_gpt2.cu b/train_gpt2.cu index c28aca5f..6ca916cc 100644 --- a/train_gpt2.cu +++ b/train_gpt2.cu @@ -1486,10 +1486,10 @@ int main(int argc, char *argv[]) { if (output_log_dir != NULL) { assert(strlen(output_log_dir) < 400); // careful bunch of hardcoded snprintf around this } - // check if output_log_dir has a "." in it, because this behavior changed May 24, 2024. take out later - if (output_log_dir != NULL && strstr(output_log_dir, ".") != NULL) { - fprintf(stderr, "-o (output_log_dir) has a '.', are you specifying a file instead of dir?\n"); - fprintf(stderr, "(note that this option changed recently, -o used to be file, became dir.)\n"); + // check if output_log_dir does not exist or is a file + struct stat st = {0}; + if (output_log_dir != NULL && (stat(output_log_dir, &st) == -1 || !S_ISDIR(st.st_mode))) { + fprintf(stderr, "-o (%s) does not exist or is a file - are you specifying a file instead of dir?\n", output_log_dir); exit(EXIT_FAILURE); } int tokens_per_fwdbwd = B * T * multi_gpu_config.num_processes; // one micro-batch processes this many tokens From 40e7289916fb28f52e19908ef6f2d37063b0fe34 Mon Sep 17 00:00:00 2001 From: Aleksa Gordic Date: Fri, 7 Jun 2024 17:49:49 +0200 Subject: [PATCH 2/2] Make it cross-platform, support Windows --- train_gpt2.cu | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/train_gpt2.cu b/train_gpt2.cu index 6ca916cc..2ac7fb23 100644 --- a/train_gpt2.cu +++ b/train_gpt2.cu @@ -1487,9 +1487,9 @@ int main(int argc, char *argv[]) { assert(strlen(output_log_dir) < 400); // careful bunch of hardcoded snprintf around this } // check if output_log_dir does not exist or is a file - struct stat st = {0}; - if (output_log_dir != NULL && (stat(output_log_dir, &st) == -1 || !S_ISDIR(st.st_mode))) { - fprintf(stderr, "-o (%s) does not exist or is a file - are you specifying a file instead of dir?\n", output_log_dir); + struct stat info; + if (output_log_dir != NULL && (stat(output_log_dir, &info ) != 0 || !(info.st_mode & S_IFDIR))) { + fprintf(stderr, "-o \"%s\" does not exist or is a file - are you specifying a file instead of dir?\n", output_log_dir); exit(EXIT_FAILURE); } int tokens_per_fwdbwd = B * T * multi_gpu_config.num_processes; // one micro-batch processes this many tokens